Skip to content
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

BUG: finfo not working, issue related to numeric.dtype #21693

Closed
DavideColdebella opened this issue Jun 8, 2022 · 2 comments
Closed

BUG: finfo not working, issue related to numeric.dtype #21693

DavideColdebella opened this issue Jun 8, 2022 · 2 comments
Labels

Comments

@DavideColdebella
Copy link

Describe the issue:

When calling np.finfo, I always get the << 'NoneType' object is not callable >> error, independently of the argument passed.
The error trace indicates that there's an error in the line

dtype = numeric.dtype(type(dtype))

and, if I do

from numpy.core import numeric
print(numeric.dtype)

I get a "None" value.

I guess it could be fixed by replacing the line above with something like:

dtype = dtype(type(dtype))

Reproduce the code example:

import numpy
np.finfo(np.float32)

Error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~\anaconda3\envs\Melanion\lib\site-packages\numpy\core\getlimits.py:384, in finfo.__new__(cls, dtype)
    383 try:
--> 384     dtype = numeric.dtype(dtype)
    385 except TypeError:
    386     # In case a float instance was given

TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Input In [62], in <cell line: 1>()
----> 1 np.finfo(
      2     # np.float16, 
      3     np.float32, 
      4     # np.float64
      5 ).dtype

File ~\anaconda3\envs\Melanion\lib\site-packages\numpy\core\getlimits.py:387, in finfo.__new__(cls, dtype)
    384     dtype = numeric.dtype(dtype)
    385 except TypeError:
    386     # In case a float instance was given
--> 387     dtype = numeric.dtype(type(dtype))
    389 obj = cls._finfo_cache.get(dtype, None)
    390 if obj is not None:

TypeError: 'NoneType' object is not callable

NumPy/Python version information:

Python Version: 3.10.4
Numpy Version: 1.21.5

@seberg
Copy link
Member

seberg commented Jun 8, 2022

See gh-21519, this is a cython issue and you must be in the situation of two things here:

  1. Using debugging or tracing (i.e. an IDE such as Spyder may be doing that "for" you)
  2. Using some other library which calls NumPy API from cython (that could be sklearn, pandas, or np.random in which case a NumPy upgrade will help)

The issue happens only with Python 3.10. It can be fixed, so long the library that causes the issue has a very recent upgrade available (using the new Cython). However, there is nothing more NumPy can do and it is tricky for us to know what is causing this.

It could very well be NumPy itself (i.e. np.random), in that case, please try upgrading NumPy.

@seberg seberg closed this as completed Jun 8, 2022
@Mark-BC
Copy link

Mark-BC commented Jul 15, 2022

I had this same problem, except it was the corresponding line in iinfo, not finfo.
Using PyCharm, but only if running In debug mode, executing

my_dtype = numpy.core.numeric.dtype(numpy.int32)

would cause

TypeError: 'NoneType' object is not callable

I solved it by upgrading Pandas from 1.4.2 to 1.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants