Skip to content

Fix: Complete patch for np.float/np.int removal in numpy>=1.24 (11 affected files) #557

Description

@znatri

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.floatnp.float64 and np.intnp.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions