cf.Data.__hash__

Data.__hash__()[source]

The built-in function hash

Generating the hash temporarily realizes the entire array in memory, which may not be possible for large arrays.

The hash value is dependent on the data type, shape of the data 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.

The hash value is not guaranteed to be portable across versions of Python, numpy and cf.

Note

The hash value may be different if regenerated.

Returns :
out : int

The hash value.

Examples

>>> print d.array
[[0 1 2 3]]
>>> d.hash()
-8125230271916303273
>>> d[1, 0] = numpy.ma.masked
>>> print d.array
[[0 -- 2 3]]
>>> hash(d)
791917586613573563
>>> d.hardmask = False
>>> d[0, 1] = 999
>>> d[0, 1] = numpy.ma.masked
>>> d.hash()
791917586613573563
>>> d.squeeze()
>>> print d.array
[0 -- 2 3]
>>> hash(d)
-7007538450787927902
>>> d.dtype = float
>>> print d.array
[0.0 -- 2.0 3.0]
>>> hash(d)
-4816859207969696442

Previous topic

cf.Data.__deepcopy__

Next topic

cf.Data.__len__

This Page