Stefan van der Walt wrote:
> 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?

It's expected, but not desired. We haven't implemented the hash function for
dtype objects, so we have the default, which is based on object identity rather
than value. It is something that should be implemented, given time.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to