Skip to content

Commit

Permalink
Backport PR matplotlib#26452: ENH: Update numpy exceptions imports
Browse files Browse the repository at this point in the history
  • Loading branch information
timhoffm authored and meeseeksmachine committed Aug 4, 2023
1 parent eb4b1ee commit a5c480d
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit a5c480d

Please sign in to comment.