Issue
I am running the following Python code in PyCharm debug mode.
import numpy as np, pandas as pd, numpy.polynomial.chebyshev as chebyshev
from pathlib import Path
home = str(Path.home())
directory = '/Downloads'
d = pd.read_csv(home+directory+'/data.csv')
np.random.seed(0)
nData = 4
data = np.random.randn(nData,2)
z = data[:,0]
y = data[:,1]
coef = chebyshev.chebfit(z,y,3)
I encounter the following error message :
TypeError: 'NoneType' object is not callable
However if I comment out the line 'd = ...', everything works fine. What is even more bizarre is that both versions run well in the run mode. What is happening here?
Stack trace for the error:
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --cmd-line --multiproc --qt-support=auto --client 127.0.0.1 --port 65032 --file /Users/PycharmProjects/pythonProject/trial.py
warning: PYDEVD_USE_CYTHON environment variable is set to 'NO'. Frame evaluator will be also disabled because it requires Cython extensions to be enabled in order to operate correctly.
/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py:1844: DeprecationWarning: currentThread() is deprecated, use current_thread() instead
dummy_thread = threading.currentThread()
Connected to pydev debugger (build 212.5457.59)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/getlimits.py", line 384, in __new__
dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/PycharmProjects/pythonProject/trial.py", line 16, in <module>
coef0 = chebyshev.chebfit(z0,y0,4)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/polynomial/chebyshev.py", line 1670, in chebfit
return pu._fit(chebvander, x, y, deg, rcond, full, w)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/polynomial/polyutils.py", line 650, in _fit
rcond = len(x)*np.finfo(x.dtype).eps
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/getlimits.py", line 387, in __new__
dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
Process finished with exit code 1
Solution
You'd need to downgrade to Python 3.9, or wait until this CPython/cython bug is fixed.
This is actually a real bug (as of 2022-04-14), and is showing up...:
Update: This bug is not present with Pandas v1.4.3, upgrading Pandas would be another solution.
Answered By - mtd
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.