diff options
| author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2023-03-06 09:43:49 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-06 09:43:49 -0500 |
| commit | 25010c16edbe54ac9449ccac9d8f1da0c2d97cb0 (patch) | |
| tree | 3d240c4406893e658637029135eaf0b0adedfed5 /numpy/ma | |
| parent | b4f6b0b9d2af3e5a7ed0bfb51c8d692298bc2dde (diff) | |
| parent | 9fe3554b33ed1c3e7c8c78a8ac97322c0a16f7cb (diff) | |
| download | numpy-25010c16edbe54ac9449ccac9d8f1da0c2d97cb0.tar.gz | |
Merge pull request #23335 from tylerjereddy/treddy_issue_22041
BUG: ma with structured dtype
Diffstat (limited to 'numpy/ma')
| -rw-r--r-- | numpy/ma/core.py | 2 | ||||
| -rw-r--r-- | numpy/ma/tests/test_regression.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 9584e56d2..fcc321a73 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2857,7 +2857,7 @@ class MaskedArray(ndarray): mask = np.array( [getmaskarray(np.asanyarray(m, dtype=_data.dtype)) for m in data], dtype=mdtype) - except ValueError: + except (ValueError, TypeError): # If data is nested mask = nomask # Force shrinking of the mask if needed (and possible) diff --git a/numpy/ma/tests/test_regression.py b/numpy/ma/tests/test_regression.py index cb3d0349f..f4f32cc7a 100644 --- a/numpy/ma/tests/test_regression.py +++ b/numpy/ma/tests/test_regression.py @@ -89,3 +89,9 @@ class TestRegression: def test_masked_array_tobytes_fortran(self): ma = np.ma.arange(4).reshape((2,2)) assert_array_equal(ma.tobytes(order='F'), ma.T.tobytes()) + + def test_structured_array(self): + # see gh-22041 + np.ma.array((1, (b"", b"")), + dtype=[("x", np.int_), + ("y", [("i", np.void), ("j", np.void)])]) |
