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

'numpy.dtype[bool_]' object is not callable when debugging code that uses Pandas #18054

Closed
DDAAVVEE888 opened this issue May 29, 2022 · 8 comments

Comments

@DDAAVVEE888
Copy link

DDAAVVEE888 commented May 29, 2022

Description

What steps will reproduce the problem?

I need to use Nelson-Siegel-Svensson regression Model but the calibrate_ns_ols function works only in the RUN mode. While it doesn't in debug mode if preceded by any pandas csv import instruction.

The resulting error is the following:
TypeError: 'numpy.dtype[bool_]' object is not callable.

here the code examples:

# error only in debug not in run
import pandas as pd
import numpy as np
from nelson_siegel_svensson.calibrate import calibrate_ns_ols

Universe=pd.read_csv('GlobalCreditUniverse.csv',sep=";",header=2)

t = np.array([0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0])
y = np.array([0.01, 0.011, 0.013, 0.016, 0.019, 0.021, 0.026, 0.03, 0.035, 0.037, 0.038, 0.04])

curve, status = calibrate_ns_ols(t, y, tau0=1.0)  # starting value of 1.0 for the optimization of tau
assert status.success
print(curve)
# works fine in debug and run
import pandas as pd
import numpy as np
from nelson_siegel_svensson.calibrate import calibrate_ns_ols

t = np.array([0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0])
y = np.array([0.01, 0.011, 0.013, 0.016, 0.019, 0.021, 0.026, 0.03, 0.035, 0.037, 0.038, 0.04])

curve, status = calibrate_ns_ols(t, y, tau0=1.0)  # starting value of 1.0 for the optimization of tau
assert status.success
print(curve)

Universe=pd.read_csv('GlobalCreditUniverse.csv',sep=";",header=2)

Versions

  • Spyder version: 5.3.1
  • Python version: 3.8.10
  • Qt version: 5.15.2
  • PyQt5 version: 5.15.6
  • Operating System: Windows 10

Dependencies

# Mandatory:
atomicwrites >=1.2.0                 :  1.4.0 (OK)
chardet >=2.0.0                      :  4.0.0 (OK)
cloudpickle >=0.5.0                  :  2.1.0 (OK)
cookiecutter >=1.6.0                 :  1.7.3 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree                         :  None (OK)
IPython >=7.31.1;<8.0.0              :  7.33.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.18.1 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.5.1 (OK)
keyring >=17.0.0                     :  23.5.1 (OK)
nbconvert >=4.0                      :  6.5.0 (OK)
numpydoc >=0.6.0                     :  1.3.1 (OK)
paramiko >=2.4.0                     :  2.11.0 (OK)
parso >=0.7.0;<0.9.0                 :  0.8.3 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.1 (OK)
pygments >=2.0                       :  2.12.0 (OK)
pylint >=2.5.0                       :  2.13.9 (OK)
pyls_spyder >=0.4.0                  :  0.4.0 (OK)
pylsp >=1.4.1;<1.5.0                 :  1.4.1 (OK)
pylsp_black >=1.2.0                  :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0            :  3.0.3 (OK)
qstylizer >=0.1.10                   :  0.2.1 (OK)
qtawesome >=1.0.2                    :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0             :  5.3.0 (OK)
qtpy >=2.1.0                         :  2.1.0 (OK)
rtree >=0.9.7                        :  1.0.0 (OK)
setuptools >=49.6.0                  :  62.3.2 (OK)
sphinx >=0.6.6                       :  4.5.0 (OK)
spyder_kernels >=2.3.1;<2.4.0        :  2.3.1 (OK)
textdistance >=4.2.0                 :  4.2.2 (OK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog                             :  2.1.8 (OK)
zmq >=22.1.0                         :  23.0.0 (OK)

# Optional:
cython >=0.21                        :  0.29.30 (OK)
matplotlib >=3.0.0                   :  3.5.2 (OK)
numpy >=1.7                          :  1.22.4 (OK)
pandas >=1.1.1                       :  1.4.2 (OK)
scipy >=0.17.0                       :  1.8.1 (OK)
sympy >=0.7.3                        :  1.10.1 (OK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)
@ccordoba12
Copy link
Member

Hey @DDAAVVEE888, thanks for reporting. How can we install this nelson_siegel_svensson package to your code examples above?

Also, we don't have the GlobalCreditUniverse.csv file, and I don't know if that's important or not.

@DDAAVVEE888
Copy link
Author

Hi, here the instructions for the installation of the package:
https://nelson-siegel-svensson.readthedocs.io/en/latest/installation.html

The csv has no relation with the function, I think that any csv import will bring this error.

(my python interpreter is Python 3.10.4)

Thanks in advance,
Dave

@ccordoba12
Copy link
Member

ccordoba12 commented May 29, 2022

After a bit of googling I found that this seems to be a problem in Pandas. Here it is the relevant issue: pandas-dev/pandas#41935, which will be fixed when Pandas 1.4.3 is released.

For now there's nothing we can do about it.

@ccordoba12 ccordoba12 added this to the v5.3.2 milestone May 29, 2022
@ccordoba12 ccordoba12 changed the title Debug mode not working: object is not callable TypeError: 'numpy.dtype[bool_]' object is not callable when debugging code that uses Pandas May 29, 2022
@ccordoba12 ccordoba12 changed the title TypeError: 'numpy.dtype[bool_]' object is not callable when debugging code that uses Pandas 'numpy.dtype[bool_]' object is not callable when debugging code that uses Pandas May 29, 2022
@DDAAVVEE888
Copy link
Author

DDAAVVEE888 commented May 29, 2022

I not sure that's a pandas problem because I tried the code in another editor and it works in both debug and run mode. Also in Spyder in run mode it works fine...

@ccordoba12
Copy link
Member

Probably in your other editor the debugger works differently. In any case, we'll wait for Pandas 1.4.3 and see because on the the issue I referenced above they clearly say that exactly this problem is caused by debuggers or profilers.

@ccordoba12 ccordoba12 modified the milestones: v5.3.2, v5.3.3 Jun 20, 2022
@ccordoba12
Copy link
Member

ccordoba12 commented Jun 28, 2022

@DDAAVVEE888, could you verify if the problem is fixed with Pandas 1.4.3, which was just released?

@Mprabhudev044
Copy link

Its fixed when updated to pandas 1.4.3

@ccordoba12 ccordoba12 removed this from the v5.3.3 milestone Jul 1, 2022
@ccordoba12
Copy link
Member

Ok, thanks for the confirmation @Mprabhudev044. Closing then.

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

No branches or pull requests

3 participants