Summary
madmom 0.16.1 uses deprecated np.float and np.int aliases removed in NumPy 1.24. This makes madmom unusable with any modern NumPy version.
This is a known issue (#527), but most workarounds only address the first file that crashes (io/__init__.py). The bare aliases actually exist in 11 files across the package, so partial patches still fail at runtime.
Error
>>> from madmom.features import DBNDownBeatTrackingProcessor
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`.
All Affected Files
| File |
Aliases |
madmom/io/__init__.py |
np.float |
madmom/evaluation/__init__.py |
np.float, np.int |
madmom/evaluation/beats.py |
np.float |
madmom/evaluation/chords.py |
np.float, np.int |
madmom/features/beats.py |
np.float, np.int |
madmom/features/notes.py |
np.float |
madmom/features/onsets.py |
np.float |
madmom/features/tempo.py |
np.float |
madmom/audio/signal.py |
np.float |
madmom/audio/filters.py |
np.float |
madmom/utils/__init__.py |
np.float, np.int |
Patch Script
I've published a complete post-install patch script that fixes all 11 files:
Gist: https://gist.github.com/znatri/2f36c7925615a32d8c9a0b66935701b3
The script:
- Locates madmom via
pip show (not import, which would crash before patching)
- Scans all
.py files recursively
- Replaces
np.float → np.float64 and np.int → np.int64 using regex negative lookahead (so np.float64, np.float32, etc. are untouched)
- Works cross-platform (macOS + Linux)
Usage
pip install Cython==3.0.10 setuptools numpy==1.26.4
pip install --no-build-isolation madmom==0.16.1
bash patch-madmom.sh
Additional Note: Build Isolation
madmom 0.16.1 also fails to build under pip's default PEP 517 build isolation because its setup.py requires Cython at compile time. The fix is to pre-install Cython and use --no-build-isolation:
pip install Cython==3.0.10 setuptools numpy==1.26.4
pip install --no-build-isolation madmom==0.16.1
Ideal Fix
A new PyPI release of madmom with these aliases updated would resolve this for everyone. PR #542 addresses this on the main branch but hasn't been released. Would it be possible to cut a 0.16.2 or 0.17 release?
Related
Summary
madmom 0.16.1 uses deprecated
np.floatandnp.intaliases removed in NumPy 1.24. This makes madmom unusable with any modern NumPy version.This is a known issue (#527), but most workarounds only address the first file that crashes (
io/__init__.py). The bare aliases actually exist in 11 files across the package, so partial patches still fail at runtime.Error
All Affected Files
madmom/io/__init__.pynp.floatmadmom/evaluation/__init__.pynp.float,np.intmadmom/evaluation/beats.pynp.floatmadmom/evaluation/chords.pynp.float,np.intmadmom/features/beats.pynp.float,np.intmadmom/features/notes.pynp.floatmadmom/features/onsets.pynp.floatmadmom/features/tempo.pynp.floatmadmom/audio/signal.pynp.floatmadmom/audio/filters.pynp.floatmadmom/utils/__init__.pynp.float,np.intPatch Script
I've published a complete post-install patch script that fixes all 11 files:
Gist: https://gist.github.com/znatri/2f36c7925615a32d8c9a0b66935701b3
The script:
pip show(notimport, which would crash before patching).pyfiles recursivelynp.float→np.float64andnp.int→np.int64using regex negative lookahead (sonp.float64,np.float32, etc. are untouched)Usage
Additional Note: Build Isolation
madmom 0.16.1 also fails to build under pip's default PEP 517 build isolation because its
setup.pyrequires Cython at compile time. The fix is to pre-install Cython and use--no-build-isolation:Ideal Fix
A new PyPI release of madmom with these aliases updated would resolve this for everyone. PR #542 addresses this on the main branch but hasn't been released. Would it be possible to cut a 0.16.2 or 0.17 release?
Related