|
8 | 8 | from . import util
|
9 | 9 |
|
10 | 10 |
|
| 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 | + |
11 | 18 | # Register the optionflag to skip whole blocks, i.e.
|
12 | 19 | # sequences of Examples without an intervening text.
|
13 | 20 | SKIPBLOCK = doctest.register_optionflag('SKIPBLOCK')
|
@@ -254,7 +261,7 @@ def check_output(self, want, got, optionflags):
|
254 | 261 | with warnings.catch_warnings():
|
255 | 262 | # NumPy's ragged array deprecation of np.array([1, (2, 3)]);
|
256 | 263 | # also array abbreviations: try `np.diag(np.arange(1000))`
|
257 |
| - warnings.simplefilter('ignore', np.VisibleDeprecationWarning) |
| 264 | + warnings.simplefilter('ignore', VisibleDeprecationWarning) |
258 | 265 |
|
259 | 266 | a_want = eval(want, dict(ns))
|
260 | 267 | a_got = eval(got, dict(ns))
|
@@ -329,7 +336,7 @@ def _do_check(self, want, got):
|
329 | 336 | pass
|
330 | 337 | with warnings.catch_warnings():
|
331 | 338 | # NumPy's ragged array deprecation of np.array([1, (2, 3)])
|
332 |
| - warnings.simplefilter('ignore', np.VisibleDeprecationWarning) |
| 339 | + warnings.simplefilter('ignore', VisibleDeprecationWarning) |
333 | 340 |
|
334 | 341 | # This line is the crux of the whole thing. The rest is mostly scaffolding.
|
335 | 342 | result = np.allclose(want, got, atol=self.atol, rtol=self.rtol)
|
|
0 commit comments