Skip to content

Commit 22657e8

Browse files
committed
ENH: Update numpy exceptions imports
1 parent d073a36 commit 22657e8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/cbook.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@
2121
import types
2222
import weakref
2323

24+
from packaging.version import parse as parse_version
2425
import numpy as np
2526

27+
if parse_version(np.__version__) >= parse_version("1.25.0"):
28+
from numpy.exceptions import VisibleDeprecationWarning
29+
else:
30+
from numpy import VisibleDeprecationWarning
31+
2632
import matplotlib
2733
from matplotlib import _api, _c_internal_utils
2834

@@ -1064,7 +1070,7 @@ def _combine_masks(*args):
10641070
raise ValueError("Masked arrays must be 1-D")
10651071
try:
10661072
x = np.asanyarray(x)
1067-
except (np.VisibleDeprecationWarning, ValueError):
1073+
except (VisibleDeprecationWarning, ValueError):
10681074
# NumPy 1.19 raises a warning about ragged arrays, but we want
10691075
# to accept basically anything here.
10701076
x = np.asanyarray(x, dtype=object)
@@ -1658,7 +1664,7 @@ def index_of(y):
16581664
pass
16591665
try:
16601666
y = _check_1d(y)
1661-
except (np.VisibleDeprecationWarning, ValueError):
1667+
except (VisibleDeprecationWarning, ValueError):
16621668
# NumPy 1.19 will warn on ragged input, and we can't actually use it.
16631669
pass
16641670
else:

0 commit comments

Comments
 (0)