question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[DeprecationWarning] np aliases of builtin types deprecated in numpy 1.20

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mattiadgcommented, Oct 21, 2022

Thanks, will do

1reaction
bmcfeecommented, Oct 21, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NumPy 1.20.0 Release Notes
Using the aliases of builtin types like np.int is deprecated#. For a long time, np.int has been an alias of the builtin int...
Read more >
How to get rid of Deprecating Warning: 'np.float' is a ...
python - How to get rid of Deprecating Warning: 'np. float' is a deprecated alias for builtin 'float' - Stack Overflow. Stack Overflow...
Read more >
Sage 9.5.beta8: ipython help triggers pythran deprecation ...
8/site-packages/pythran/tables.py:4520: DeprecationWarning: `np.complex` is a deprecated alias for the builtin `complex`. To silence this ...
Read more >
Starting with Topic Modelling | Kaggle
Deprecated in NumPy 1.20 ; for more details and guidance: ... DeprecationWarning: `np.object` is a deprecated alias for the builtin `object`.
Read more >
numpy.bool is deprecated (#18268) · Issues · VTK / VTK - GitLab
The usage of numpy.bool has been deprecated as of Numpy 1.20. Instead, it's recommended to either use the built in python bool or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found