diff --git a/find_dupes.py b/find_dupes.py index ce6e8f3..19bc894 100644 --- a/find_dupes.py +++ b/find_dupes.py @@ -93,9 +93,10 @@ def main(): n = len(names) print(f"Pairwise compare {n}x{n} (numpy hamming) ...") dmat = np.array([data[f][0] for f in names], dtype=np.uint64) - # hamming distances via xor + popcount - x = dmat[:, None] ^ dmat[None, :] - ham = np.zeros_like(x) + # hamming distances via xor + popcount (work in int64; numpy has no + # sane uint64 shift-add promotion) + x = (dmat[:, None] ^ dmat[None, :]).astype(np.int64) + ham = np.zeros(x.shape, dtype=np.int16) for b in range(64): ham += ((x >> b) & 1).astype(np.int16)