Skip to content

Commit

Permalink
[Fix] Fix numpy.core.einsumfunc deprecation (#628)
Browse files Browse the repository at this point in the history
After the 1.7.0 release I noticed the following deprecation warning:
```
autograd/numpy/numpy_wrapper.py:7: DeprecationWarning: numpy.core.einsumfunc is deprecated and has been renamed to numpy._core.einsumfunc. The numpy._core namespace contains private NumPy internals and its use is discouraged, as NumPy internals can change without warning in any release. In practice, most real-world usage of numpy.core is to access functionality in the public NumPy API. If that is the case, use the public NumPy API. If not, you are using NumPy internals. If you would still like to access an internal attribute, use numpy._core.einsumfunc._parse_einsum_input.
```

This PR simply replaces the import from `numpy.core.einsumfunc` by
`numpy._core.einsumfunc` which should fix the warning but adds the risk
that `_parse_einsum_input` might break in a furture numpy release
without prior warning.
  • Loading branch information
fjosw committed Aug 23, 2024
1 parent 2f6cc22 commit e88afef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autograd/numpy/numpy_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from autograd.extend import primitive, notrace_primitive
import numpy as _np
import autograd.builtins as builtins
from numpy.core.einsumfunc import _parse_einsum_input

if _np.lib.NumpyVersion(_np.__version__) >= '2.0.0':
from numpy._core.einsumfunc import _parse_einsum_input
else:
from numpy.core.einsumfunc import _parse_einsum_input

notrace_functions = [
_np.ndim, _np.shape, _np.iscomplexobj, _np.result_type
Expand Down

0 comments on commit e88afef

Please sign in to comment.