sigsep / sigsep-mus-eval

museval - source separation evaluation tools for python
https://sigsep.github.io/sigsep-mus-eval/
MIT License
202 stars 36 forks source link

bss_eval crashes with numpy==1.24.0 #87

Closed mackcmillion closed 1 year ago

mackcmillion commented 1 year ago

The following code runs fine for museval==0.4.0 and numpy==1.23.5, but crashes with numpy==1.24.0:

import numpy as np
import museval

def main():
    references = np.random.random((4, 44100 * 10, 2))
    estimates = np.random.random((4, 44100 * 10, 2))

    scores = museval.metrics.bss_eval(
        references,
        estimates,
        compute_permutation=False,
        window=44100,
        hop=44100,
        framewise_filters=False,
        bsseval_sources_version=False
    )

    print(scores)

if __name__ == '__main__':
    main()

The corresponding stacktrace is the following:

Traceback (most recent call last):
  File "/Users/max/arunmixer-lab/museval_issue_demo.py", line 23, in <module>
    main()
  File "/Users/max/arunmixer-lab/museval_issue_demo.py", line 9, in main
    scores = museval.metrics.bss_eval(
  File "/Users/max/opt/miniconda3/envs/arunmixer-lab/lib/python3.9/site-packages/museval/metrics.py", line 282, in bss_eval
    (G, sf, C) = compute_GsfC()
  File "/Users/max/opt/miniconda3/envs/arunmixer-lab/lib/python3.9/site-packages/museval/metrics.py", line 263, in compute_GsfC
    C[jtrue] = _compute_projection_filters(
  File "/Users/max/opt/miniconda3/envs/arunmixer-lab/lib/python3.9/site-packages/museval/metrics.py", line 554, in _compute_projection_filters
    eps = np.finfo(np.float).eps
  File "/Users/max/opt/miniconda3/envs/arunmixer-lab/lib/python3.9/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'float'

Apparently, np.float has been removed in 1.24.0 as it has been deprecated since 1.20.0.

Considering the deprecation message that appears in 1.23.5 a fix would be as easy as replacing all occurrences of np.float with the Python builtin float:

DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
faroit commented 1 year ago

@mackcmillion Thanks for the note. Are you able to provide a PR?

mackcmillion commented 1 year ago

I've never contributed to an open source project before, but I'm sure I could figure it out. However, I'll be out for Christmas the next two weeks, so I could only have a look at it in two weeks time.

faroit commented 1 year ago

fixed in new release