[Numpy-discussion] dtype hashes are not equal

Stefan van der Walt stefan at sun.ac.za
Sun May 13 13:03:03 EDT 2007


Hi all,

In the numpy.sctypes dictionary, there are two entries for uint32:

In [2]: N.sctypes['uint']
Out[2]: 
[<type 'numpy.uint8'>,
 <type 'numpy.uint16'>,
 <type 'numpy.uint32'>,
 <type 'numpy.uint32'>,
 <type 'numpy.uint64'>]

Comparing the dtypes of the two types gives the correct answer:

In [3]: sc = N.sctypes['uint']

In [4]: N.dtype(sc[2]) == N.dtype(sc[3])
Out[4]: True

But the hash values for the dtypes (and the types) differ:

In [42]: for T in N.sctypes['uint']:
    dt = N.dtype(T)
    print T, dt
    print '=>', hash(T), hash(dt)

<type 'numpy.uint8'> uint8
=> -1217082432 -1217078592
<type 'numpy.uint16'> uint16
=> -1217082240 -1217078464
<type 'numpy.uint32'> uint32
=> -1217081856 -1217078336
<type 'numpy.uint32'> uint32
=> -1217082048 -1217078400
<type 'numpy.uint64'> uint64
=> -1217081664 -1217078208

Is this expected/correct behaviour?

Cheers
Stéfan



More information about the NumPy-Discussion mailing list