dtype comparison and hashing - bug?
![](https://secure.gravatar.com/avatar/b4929294417e9ac44c17967baae75a36.jpg?s=120&d=mm&r=g)
Hi, I have just run into this oddness: In [28]: dt1 = np.dtype('f4') In [29]: dt1.str Out[29]: '<f4' In [30]: dt2 = dt1.newbyteorder('<') In [31]: dt2.str Out[31]: '<f4' In [32]: dt1 == dt2 Out[32]: True In [33]: hash(dt1) == hash(dt2) Out[33]: False This is the same as: http://www.mail-archive.com/numpy-discussion@scipy.org/msg13299.html My question was - does the team still agree this is a bug? Can anyone offer a pointer as to how it should be fixed? Best, Matthew
![](https://secure.gravatar.com/avatar/59bdb3784070f0a6836aca9ee03ad817.jpg?s=120&d=mm&r=g)
On Wed, Oct 20, 2010 at 5:08 PM, Matthew Brett <matthew.brett@gmail.com> wrote:
Hi,
I have just run into this oddness:
In [28]: dt1 = np.dtype('f4')
In [29]: dt1.str Out[29]: '<f4'
In [30]: dt2 = dt1.newbyteorder('<')
In [31]: dt2.str Out[31]: '<f4'
In [32]: dt1 == dt2 Out[32]: True
In [33]: hash(dt1) == hash(dt2) Out[33]: False
This is the same as:
http://www.mail-archive.com/numpy-discussion@scipy.org/msg13299.html
My question was - does the team still agree this is a bug?
This should have been fixed when I implemented the hashing protocol for dtypes. This is a bug in the hashing protocol implementation, most likely caused by "=" and "<" being considered different by the hashing function. I will try to take a look at it (the function to fix is _array_descr_builtin in hashdesc.c if you feel like doing some C right now :) ). cheers, David
![](https://secure.gravatar.com/avatar/da3a0a1942fbdc5ee9a9b8115ac5dae7.jpg?s=120&d=mm&r=g)
Wed, 20 Oct 2010 17:46:06 +0900, David Cournapeau wrote: [clip]
This should have been fixed when I implemented the hashing protocol for dtypes. This is a bug in the hashing protocol implementation, most likely caused by "=" and "<" being considered different by the hashing function. I will try to take a look at it (the function to fix is _array_descr_builtin in hashdesc.c if you feel like doing some C right now :) ).
It already has a ticket :) http://projects.scipy.org/numpy/ticket/1637 But I haven't yet felt the urge to fix it. Pauli
![](https://secure.gravatar.com/avatar/b4929294417e9ac44c17967baae75a36.jpg?s=120&d=mm&r=g)
Hi,
It already has a ticket :)
Oops - sorry - thanks for point that out. Cheers, Matthew
participants (3)
-
David Cournapeau
-
Matthew Brett
-
Pauli Virtanen