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

Skip to content

Backport PR #26452 on branch v3.7.x (ENH: Update numpy exceptions imports) #26455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

import numpy as np

try:
from numpy.exceptions import VisibleDeprecationWarning # numpy >= 1.25
except ImportError:
from numpy import VisibleDeprecationWarning

import matplotlib
from matplotlib import _api, _c_internal_utils

Expand Down Expand Up @@ -1065,7 +1070,7 @@ def _combine_masks(*args):
raise ValueError("Masked arrays must be 1-D")
try:
x = np.asanyarray(x)
except (np.VisibleDeprecationWarning, ValueError):
except (VisibleDeprecationWarning, ValueError):
# NumPy 1.19 raises a warning about ragged arrays, but we want
# to accept basically anything here.
x = np.asanyarray(x, dtype=object)
Expand Down Expand Up @@ -1659,7 +1664,7 @@ def index_of(y):
pass
try:
y = _check_1d(y)
except (np.VisibleDeprecationWarning, ValueError):
except (VisibleDeprecationWarning, ValueError):
# NumPy 1.19 will warn on ragged input, and we can't actually use it.
pass
else:
Expand Down