diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-12-03 10:42:29 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-12-03 10:42:29 -0700 |
commit | d69d51c0d26fef3f8914aaa3d9af21348fe7a043 (patch) | |
tree | 36f03fdd9990695bfbcf203c2e884d3c5e27c3b8 /numpy | |
parent | 1a097894a6da019a1bc728f96eb40b33a584d05d (diff) | |
parent | c8a09822c707f320d8c8ac242a8628de690a5899 (diff) | |
download | numpy-d69d51c0d26fef3f8914aaa3d9af21348fe7a043.tar.gz |
Merge pull request #6761 from gerritholl/structured_nested_masked_array_maskfill
BUG/TST: Fix #6760 by correctly describing mask on nested subdtypes
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/ma/core.py | 2 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 9cc1a1272..ebc335a85 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -1248,7 +1248,7 @@ def _recursive_make_descr(datatype, newtype=bool_): # Is this some kind of composite a la (np.float,2) elif datatype.subdtype: mdescr = list(datatype.subdtype) - mdescr[0] = newtype + mdescr[0] = _recursive_make_descr(datatype.subdtype[0], newtype) return tuple(mdescr) else: return newtype diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 2fdd00484..369138471 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -608,6 +608,13 @@ class TestMaskedArray(TestCase): control = np.array([(0, 1), (2, 0)], dtype=a['B'].dtype) assert_equal(test, control) + # test if mask gets set correctly (see #6760) + Z = numpy.ma.zeros(2, numpy.dtype([("A", "(2,2)i1,(2,2)i1", (2,2))])) + assert_equal(Z.data.dtype, numpy.dtype([('A', [('f0', 'i1', (2, 2)), + ('f1', 'i1', (2, 2))], (2, 2))])) + assert_equal(Z.mask.dtype, numpy.dtype([('A', [('f0', '?', (2, 2)), + ('f1', '?', (2, 2))], (2, 2))])) + def test_filled_w_f_order(self): # Test filled w/ F-contiguous array a = array(np.array([(0, 1, 2), (4, 5, 6)], order='F'), |