|
14 | 14 | from astropy import units as u |
15 | 15 | from astropy.coordinates import Longitude |
16 | 16 | from astropy.units import Quantity |
| 17 | +from astropy.utils.compat import NUMPY_LT_2_0 |
17 | 18 | from astropy.utils.compat.optional_deps import HAS_PLT |
18 | 19 | from astropy.utils.masked import Masked, MaskedNDArray |
19 | 20 |
|
@@ -1395,12 +1396,16 @@ def test_masked_str_explicit_structured(): |
1395 | 1396 | sa = np.array([(1.0, 2.0), (3.0, 4.0)], dtype="f8,f8") |
1396 | 1397 | msa = Masked(sa, [(False, True), (False, False)]) |
1397 | 1398 | assert str(msa) == "[(1., ——) (3., 4.)]" |
1398 | | - assert str(msa[0]) == "(1., ——)" |
1399 | | - assert str(msa[1]) == "(3., 4.)" == str(sa[1]) |
| 1399 | + assert str(msa[0]) == ("(1., ——)" if NUMPY_LT_2_0 else "(1.0, ———)") |
| 1400 | + assert str(msa[1]) == str(sa[1]) == ("(3., 4.)" if NUMPY_LT_2_0 else "(3.0, 4.0)") |
1400 | 1401 | with np.printoptions(precision=3, floatmode="fixed"): |
1401 | 1402 | assert str(msa) == "[(1.000, ———) (3.000, 4.000)]" |
1402 | | - assert str(msa[0]) == "(1.000, ———)" |
1403 | | - assert str(msa[1]) == "(3.000, 4.000)" == str(sa[1]) |
| 1403 | + assert str(msa[0]) == ("(1.000, ———)" if NUMPY_LT_2_0 else "(1.0, ———)") |
| 1404 | + assert ( |
| 1405 | + str(msa[1]) |
| 1406 | + == str(sa[1]) |
| 1407 | + == ("(3.000, 4.000)" if NUMPY_LT_2_0 else "(3.0, 4.0)") |
| 1408 | + ) |
1404 | 1409 |
|
1405 | 1410 |
|
1406 | 1411 | def test_masked_repr_explicit_structured(): |
|
0 commit comments