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

module 'numpy' has no attribute 'float' #139

Closed
ratoci opened this issue Jan 11, 2023 · 3 comments
Closed

module 'numpy' has no attribute 'float' #139

ratoci opened this issue Jan 11, 2023 · 3 comments

Comments

@ratoci
Copy link

ratoci commented Jan 11, 2023

I get a frequent error in many modules,
I’m using Mac OS version with python 3.10 and all the required extension installed and library compiled. Here’s the error message:

File "/usr/local/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tkinter/init.py", line 1921, in call
return self.func(*args)
File "/Users/ratox/Dropbox/Script/sms-tools-master/software/models_interface/hpsModel_GUI_frame.py", line 198, in compute_model
hpsModel_function.main(inputFile, window, M, N, t, minSineDur, nH, minf0, maxf0, f0et, harmDevSlope, stocf)
File "/Users/ratox/Dropbox/Script/sms-tools-master/software/models_interface/hpsModel_function.py", line 37, in main
hfreq, hmag, hphase, stocEnv = HPS.hpsModelAnal(x, fs, w, N, H, t, nH, minf0, maxf0, f0et, harmDevSlope, minSineDur, Ns, stocf)
File "/Users/ratox/Dropbox/Script/sms-tools-master/software/models_interface/../models/hpsModel.py", line 27, in hpsModelAnal
hfreq, hmag, hphase = HM.harmonicModelAnal(x, fs, w, N, H, t, nH, minf0, maxf0, f0et, harmDevSlope, minSineDur)
File "/Users/ratox/Dropbox/Script/sms-tools-master/software/models_interface/../models/harmonicModel.py", line 185, in harmonicModelAnal
f0t = UF.f0Twm(ipfreq, ipmag, f0et, minf0, maxf0, f0stable) # find f0
File "/Users/ratox/Dropbox/Script/sms-tools-master/software/models_interface/../models/utilFunctions.py", line 306, in f0Twm
f0, f0error = UF_C.twm(pfreq, pmag, f0cf) # call the TWM function with peak candidates, cython version
File "cutilFunctions.pyx", line 23, in utilFunctions_C.twm (cutilFunctions.c:1466)
File "/usr/local/lib/python3.10/site-packages/numpy/init.py", line 284, in getattr
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'

@marcoslhc
Copy link
Contributor

This happens because numpy removed support for np.float in version 1.24.
this PR is a workaround: #141

@egndz
Copy link

egndz commented Jan 21, 2024

Similar to @ratoci's issue:

I am getting the following error:

Traceback (most recent call last): File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 1948, in __call__ return self.func(*args) ^^^^^^^^^^^^^^^^ File "/Users/egehangunduz/Desktop/github/sms-tools/software/models_interface/sineModel_GUI_frame.py", line 154, in compute_model sineModel_function.main(inputFile, window, M, N, t, minSineDur, maxnSines, freqDevOffset, freqDevSlope) File "/Users/egehangunduz/Desktop/github/sms-tools/software/models_interface/sineModel_function.py", line 37, in main tfreq, tmag, tphase = SM.sineModelAnal(x, fs, w, N, H, t, maxnSines, minSineDur, freqDevOffset, freqDevSlope) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/egehangunduz/Desktop/github/sms-tools/software/models_interface/../models/sineModel.py", line 166, in sineModelAnal tfreq, tmag, tphase = sineTracking(ipfreq, ipmag, ipphase, tfreq, freqDevOffset, freqDevSlope) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/egehangunduz/Desktop/github/sms-tools/software/models_interface/../models/sineModel.py", line 25, in sineTracking pindexes = np.array(np.nonzero(pfreq), dtype=np.int)[0] # indexes of current peaks ^^^^^^ File "/Users/egehangunduz/Desktop/github/sms-tools/env/lib/python3.11/site-packages/numpy/__init__.py", line 324, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'int'.np.intwas a deprecated alias for the builtinint. To avoid this error in existing code, use intby itself. Doing this will not modify any behavior and is safe. When replacingnp.int, you may wish to use e.g. np.int64ornp.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

`

OS: MacOS Sonoma 14.2.1
Python Version: 3.11.7
numpy: 1.26.3

Should we use PR #141 for temporary fix or move to the permanent solution?

@alastair
Copy link
Member

We upgraded cython, which no longer uses this attribute when building the extension. This works with the latest available 1.x version of numpy

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

No branches or pull requests

4 participants