Hi,
anyone has idea how to hash numpy boolean array in nopython mode?
I have a loop which generates np.bool arrays and I need to save ONLY UNIQUE arrays into tuple with results.
Current implementation of hashing gives false-positive results on large arrays…
import numpy as np
import numba as nb
@nb.njit()
def unique_arrays(arrays):
results = dict()
for i in range(len(arrays)):
# some hash func...
h = arrays[i].nonzero()[0].sum()
if h not in results:
results[h] = arrays[i]
return results
arrays = np.array([
[False, False, False],
[True, True, True],
[False, False, False],
])
unique_arrays(arrays)