find_dupes: fix uint64 hamming accumulation (numpy casts to float64)
This commit is contained in:
+4
-3
@@ -93,9 +93,10 @@ def main():
|
|||||||
n = len(names)
|
n = len(names)
|
||||||
print(f"Pairwise compare {n}x{n} (numpy hamming) ...")
|
print(f"Pairwise compare {n}x{n} (numpy hamming) ...")
|
||||||
dmat = np.array([data[f][0] for f in names], dtype=np.uint64)
|
dmat = np.array([data[f][0] for f in names], dtype=np.uint64)
|
||||||
# hamming distances via xor + popcount
|
# hamming distances via xor + popcount (work in int64; numpy has no
|
||||||
x = dmat[:, None] ^ dmat[None, :]
|
# sane uint64 shift-add promotion)
|
||||||
ham = np.zeros_like(x)
|
x = (dmat[:, None] ^ dmat[None, :]).astype(np.int64)
|
||||||
|
ham = np.zeros(x.shape, dtype=np.int16)
|
||||||
for b in range(64):
|
for b in range(64):
|
||||||
ham += ((x >> b) & 1).astype(np.int16)
|
ham += ((x >> b) & 1).astype(np.int16)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user