How to hash bool numpy array in nopython mode?

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)

Hi @2W-12

Are you asking for a suitable hashing algorithm for computing the hash of a boolean NumPy array? If so, this might be a question for stackoverflow or some NumPy forum as the use of Numba is secondary to deciding on that algorithm?