Skip to content

Commit 1b411f7

Browse files
authored
Merge pull request #146 from ev-br/np2.0
MAINT: Adapt to NumPy 2.0
2 parents 2af7ffa + f025c9a commit 1b411f7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
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)

scpdt/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def matplotlib_make_nongui():
2727
try:
2828
# Matplotlib issues UserWarnings on plt.show() with a non-GUI backend,
2929
# Filter them out.
30+
# UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
3031
with warnings.catch_warnings():
31-
warnings.filterwarnings("ignore", "Matplotlib", UserWarning)
32+
warnings.filterwarnings("ignore", "FigureCanvasAgg", UserWarning)
3233
yield backend
3334
finally:
3435
if backend:

0 commit comments

Comments
 (0)