From 3cbcce5e4ab4db0a88e5d500751d46a36ceb86e1 Mon Sep 17 00:00:00 2001 From: Keisuke OGAKI Date: Mon, 16 Oct 2023 09:50:54 +0900 Subject: [PATCH] Better numpy compatibility (#48) * :art: lessen dependencies * :fire: remove py3.5 tests * texmex-python as extra package * cannot installed with python3.10 * :star: fix to be able to use recent numpy * :star: test with recent python * 3.11 is not yet supported * not yet compatible with 3.10 --------- Co-authored-by: Keisuke Ogaki --- .github/workflows/test.yml | 2 +- pqkmeans/encoder/pq_encoder.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6146d03..234f9b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: max-parallel: 3 matrix: platform: [ubuntu-latest] - python-version: ["3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9"] # 3.10, 3.11 is not yet supported steps: - uses: actions/checkout@v2 diff --git a/pqkmeans/encoder/pq_encoder.py b/pqkmeans/encoder/pq_encoder.py index 513b9fb..9ac922a 100644 --- a/pqkmeans/encoder/pq_encoder.py +++ b/pqkmeans/encoder/pq_encoder.py @@ -22,9 +22,9 @@ def fit(self, x_train): self.Ds = int(D / self.M) assert self.trained_encoder is None, "fit must be called only once" - codewords = numpy.zeros((self.M, self.Ks, self.Ds), dtype=numpy.float) + codewords = numpy.zeros((self.M, self.Ks, self.Ds), dtype=float) for m in range(self.M): - x_train_sub = x_train[:, m * self.Ds: (m + 1) * self.Ds].astype(numpy.float) + x_train_sub = x_train[:, m * self.Ds: (m + 1) * self.Ds].astype(float) codewords[m], _ = kmeans2(x_train_sub, self.Ks, iter=self.iteration, minit='points') self.trained_encoder = TrainedPQEncoder(codewords, self.code_dtype) @@ -66,7 +66,7 @@ def decode_multi(self, codes): assert M == self.M assert codes.dtype == self.code_dtype - decoded = numpy.empty((N, self.Ds * self.M), dtype=numpy.float) + decoded = numpy.empty((N, self.Ds * self.M), dtype=float) for m in range(self.M): decoded[:, m * self.Ds: (m + 1) * self.Ds] = self.codewords[m][codes[:, m], :] return decoded