Skip to content

NumPy scalars are not collections.Hashable on Python 3 #5562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shoyer opened this issue Feb 12, 2015 · 3 comments
Closed

NumPy scalars are not collections.Hashable on Python 3 #5562

shoyer opened this issue Feb 12, 2015 · 3 comments
Labels
00 - Bug 57 - Close? Issues which may be closable unless discussion continued

Comments

@shoyer
Copy link
Member

shoyer commented Feb 12, 2015

xref: pandas-dev/pandas#9276

For example:

In [1]: import numpy as np

In [2]: import collections

In [3]: isinstance(3.14, collections.Hashable)
Out[3]: True

In [4]: isinstance(np.float64(3.14), collections.Hashable)
Out[4]: False

On Python 2.7, the last output here is True (which is the correct value)

@sylviamic
Copy link

This peculiarity seems to be limited in scope - I only see it with np.float(64) in my short tests.

In [4]: isinstance(np.float32(3.14), collections.Hashable)
Out[4]: True

In [5]: isinstance(np.float64(3.14), collections.Hashable)
Out[5]: False

In [6]: isinstance(np.float128(3.14), collections.Hashable)
Out[6]: True

In [7]: isinstance(np.float(3.14), collections.Hashable)
Out[7]: True

In [8]: isinstance(np.int(3.14), collections.Hashable)
Out[8]: True

I'm not sure where these types are implemented, but I think this afternoon I'm going to poke around the code and look to see what differences there are between the different float types.

@mattip
Copy link
Member

mattip commented Jan 21, 2019

Cannot reproduce on linux64, numpy 1.13, numpy 1.16, python 3.6.6.

@mattip mattip added 00 - Bug 57 - Close? Issues which may be closable unless discussion continued labels Jan 21, 2019
@mattip
Copy link
Member

mattip commented Feb 14, 2019

Closing. Please reopen or open a new issue if the issue can be reproduced

@mattip mattip closed this as completed Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 57 - Close? Issues which may be closable unless discussion continued
Projects
None yet
Development

No branches or pull requests

3 participants