Skip to content

Commit 5d77c74

Browse files
committed
MAINT: numpy 2.0 moved VisibleDeprecationWarning
1 parent 2af7ffa commit 5d77c74

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scpdt/impl.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
from . import util
99

1010

11+
## shim numpy 1.x vs 2.0
12+
if np.__version__ < "2":
13+
VisibleDeprecationWarning = np.VisibleDeprecationWarning
14+
else:
15+
VisibleDeprecationWarning = np.exceptions.VisibleDeprecationWarning
16+
17+
1118
# Register the optionflag to skip whole blocks, i.e.
1219
# sequences of Examples without an intervening text.
1320
SKIPBLOCK = doctest.register_optionflag('SKIPBLOCK')
@@ -254,7 +261,7 @@ def check_output(self, want, got, optionflags):
254261
with warnings.catch_warnings():
255262
# NumPy's ragged array deprecation of np.array([1, (2, 3)]);
256263
# also array abbreviations: try `np.diag(np.arange(1000))`
257-
warnings.simplefilter('ignore', np.VisibleDeprecationWarning)
264+
warnings.simplefilter('ignore', VisibleDeprecationWarning)
258265

259266
a_want = eval(want, dict(ns))
260267
a_got = eval(got, dict(ns))
@@ -329,7 +336,7 @@ def _do_check(self, want, got):
329336
pass
330337
with warnings.catch_warnings():
331338
# NumPy's ragged array deprecation of np.array([1, (2, 3)])
332-
warnings.simplefilter('ignore', np.VisibleDeprecationWarning)
339+
warnings.simplefilter('ignore', VisibleDeprecationWarning)
333340

334341
# This line is the crux of the whole thing. The rest is mostly scaffolding.
335342
result = np.allclose(want, got, atol=self.atol, rtol=self.rtol)

0 commit comments

Comments
 (0)