Skip to content

types compare as not-equal (e.g. np.int32 != np.int32) #14667

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
jbrockmendel opened this issue Oct 9, 2019 · 3 comments
Closed

types compare as not-equal (e.g. np.int32 != np.int32) #14667

jbrockmendel opened this issue Oct 9, 2019 · 3 comments
Labels
33 - Question Question about NumPy usage or development

Comments

@jbrockmendel
Copy link
Contributor

From https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=18674

>           assert res_type == ex_type
E           AssertionError: assert <class 'numpy.int32'> == <class 'numpy.int32'>

I've also seen this for assert np.uint64 == np.uint64 failing. Is this behavior intentional?

@eric-wieser
Copy link
Member

eric-wieser commented Oct 9, 2019

In 1.18 (#10151), this will fail with the somewhat clearer AssertionError: assert <class 'numpy.int32'> == <class 'numpy.intc'>. The docstrings perhaps clarify what is going on a little:

In [14]: import inspect

In [15]: print(inspect.getdoc(np.int32))
Signed integer type, compatible with Python `int` anc C ``long``.
Character code: ``'l'``.
Canonical name: ``np.int_``.
Alias *on this platform*: ``np.int32``: 32-bit signed integer (-2147483648 to 2147483647).

In [16]: print(inspect.getdoc(np.intc))
Signed integer type, compatible with C ``int``.
Character code: ``'i'``.

If there is a bug here, it is probably that somewhere in your computation, an np.int_ got replaced with an np.intc, which is inconsistent. If you can trace that down, then we could consider fixing it.

@jbrockmendel
Copy link
Contributor Author

Thanks, I'll look into this.

@rossbar rossbar added the 33 - Question Question about NumPy usage or development label Jul 22, 2020
@eric-wieser
Copy link
Member

#10151 is merged, so this can be closed - the error message will be clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
33 - Question Question about NumPy usage or development
Projects
None yet
Development

No branches or pull requests

3 participants