cf.hash_array

cf.hash_array(array, algorithm=None)[source]

Return a hash value of a numpy array.

Deprecated at version 3.15.0 and is no longer available. Use dask.base.tokenize instead.

The hash value is dependent on the data type and the shape of the array. If the array is a masked array then the hash value is independent of the fill value and of data array values underlying any masked elements.

Parameters
array: numpy.ndarray

The numpy array to be hashed. May be a masked array.

algorithm: hashlib constructor function

Constructor function for the desired hash algorithm, e.g. hashlib.md5, hashlib.sha256, etc.

New in version 3.14.0.

Returns
int

The hash value.

Examples

>>> a = np.array([[0, 1, 2, 3]])
>>> cf.hash_array(a)
-5620332080097671134
>>> a = np.ma.array([[0, 1, 2, 3]], mask=[[0, 1, 0, 0]])
>>> cf.hash_array(array)
8372868545804866378
>>> a[0, 1] = 999
>>> a[0, 1] = np.ma.masked
>>> print(a)
[[0 -- 2 3]]
>>> print(a.data)
[[  0 999   2   3]]
>>> cf.hash_array(a)
8372868545804866378
>>> a = a.astype(float)
>>> cf.hash_array(a)
5950106833921144220