From 4816b007c0f793d247ab24e86acf0bc6bfdd337d Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Oct 2026 18:42:51 -0400 Subject: [PATCH] find_dupes: fix uint64 hamming accumulation (numpy casts to float64) --- find_dupes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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)