[DeprecationWarning] np aliases of builtin types deprecated in numpy 1.20
See original GitHub issueDescribe the bug Numpy deprecated their aliases of built-in types in NumPy 1.20 (https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations) and that triggers a warning every time one of these aliases is used. I am using librosa 0.6.2, but I’ve seen that aliases are also used in the 0.8.2 version (the latest as of now)
To Reproduce
from librosa.util import utils
import numpy as np
arr = np.random.rand(3,2)
utils.normalize(arr)
Expected behavior
/usr/local/lib/python3.7/dist-packages/librosa/util/utils.py:724: 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
mag = np.abs(S).astype(np.float)
Solution As the same warning suggests, change all aliases for the built-in types.
Disclaimer Please, note that this is my first issue reported ever, and I’m still familiarizing myself with it. I would happily fork the code and change these aliases, but I don’t know if it’s better to have a short discussion about it first.
Software versions*
import platform; print(platform.platform())
Linux-4.19.0-16-amd64-x86_64-with-debian-10.2
import sys; print(“Python”, sys.version)
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0]
import numpy; print(“NumPy”, numpy.version)
NumPy 1.20.1
import scipy; print(“SciPy”, scipy.version)
SciPy 1.4.1
import librosa; print(“librosa”, librosa.version)
librosa 0.6.2
librosa.show_versions()
INSTALLED VERSIONS
------------------
python: 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0]
librosa: 0.6.2
audioread: 2.1.9
numpy: 1.20.1
scipy: 1.4.1
sklearn: 0.24.1
joblib: 1.0.1
decorator: 4.4.2
six: 1.12.0
resampy: 0.2.2
numpydoc: None
sphinx: None
sphinx_rtd_theme: None
sphinxcontrib.versioning: None
matplotlib: None
numba: 0.47.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
Thanks, will do
Good catch @mattiadg - it looks like we fixed it in one place (dtype_r2c) but missed it in the reverse (dtype_c2r). This should be an easy fix if you want to PR.