Thanks to visit codestin.com
Credit goes to github.com

Skip to content

numpy.core is deprecated as of Numpy 2.0 #234

Open
@domdfcoding

Description

@domdfcoding

Accessing numpy.core, as quantities does in just one place, triggers a deprecation warning.

def _d_clip(a1, a2, a3, q):
return q.dimensionality
try:
p_dict[np.core.umath.clip] = _d_clip
except AttributeError:
pass # For compatibility with Numpy < 1.17 when clip wasn't a ufunc yet

$ python3 -Werror -c "import quantities"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/venv/lib/python3.9/site-packages/quantities/__init__.py", line 273, in <module>
    from . import quantity
  File "/tmp/venv/lib/python3.9/site-packages/quantities/quantity.py", line 10, in <module>
    from .dimensionality import Dimensionality, p_dict
  File "/tmp/venv/lib/python3.9/site-packages/quantities/dimensionality.py", line 333, in <module>
    p_dict[np.core.umath.clip] = _d_clip
  File "/tmp/venv/lib/python3.9/site-packages/numpy/core/__init__.py", line 31, in __getattr__
    _raise_warning(attr_name)
  File "/tmp/venv/lib/python3.9/site-packages/numpy/core/_utils.py", line 10, in _raise_warning
    warnings.warn(
DeprecationWarning: numpy.core is deprecated and has been renamed to numpy._core. 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.umath.

The module still exists but has been made private as numpy._core. I have searched for a direct alternative to umath.clip but can't find one listed.

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