|
69 | 69 |
|
70 | 70 | FP_RUNTIME_WARN = Version(np.__version__) >= Version('1.24.0.dev0+239') |
71 | 71 |
|
| 72 | +try: |
| 73 | + from numpy.exceptions import ComplexWarning |
| 74 | +except ModuleNotFoundError: # NumPy < 1.25 |
| 75 | + from numpy import ComplexWarning |
| 76 | + |
72 | 77 |
|
73 | 78 | def test__is_compressed_fobj(): |
74 | 79 | # _is_compressed helper function |
@@ -610,7 +615,7 @@ def test_a2f_bad_scaling(): |
610 | 615 | if np.issubdtype(in_type, np.complexfloating) and not np.issubdtype( |
611 | 616 | out_type, np.complexfloating |
612 | 617 | ): |
613 | | - cm = pytest.warns(np.ComplexWarning) |
| 618 | + cm = pytest.warns(ComplexWarning) |
614 | 619 | if (slope, inter) == (1, 0): |
615 | 620 | with cm: |
616 | 621 | assert_array_equal( |
@@ -650,7 +655,7 @@ def test_a2f_nan2zero_range(): |
650 | 655 | arr = np.array([-1, 0, 1, np.nan], dtype=dt) |
651 | 656 | # Error occurs for arrays without nans too |
652 | 657 | arr_no_nan = np.array([-1, 0, 1, 2], dtype=dt) |
653 | | - complex_warn = (np.ComplexWarning,) if np.issubdtype(dt, np.complexfloating) else () |
| 658 | + complex_warn = (ComplexWarning,) if np.issubdtype(dt, np.complexfloating) else () |
654 | 659 | # Casting nan to int will produce a RuntimeWarning in numpy 1.24 |
655 | 660 | nan_warn = (RuntimeWarning,) if FP_RUNTIME_WARN else () |
656 | 661 | c_and_n_warn = complex_warn + nan_warn |
|
0 commit comments