Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better numpy compatibility #48

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pqkmeans/encoder/pq_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware that the numpy.float style has been deprecated!

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)

Expand Down Expand Up @@ -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
Loading