summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-12-01 07:34:35 -0700
committerCharles Harris <charlesr.harris@gmail.com>2015-12-01 07:34:35 -0700
commit433e6691113c4656cd939f94da4a837ed08e59a4 (patch)
treeaa1224ac2147fdca63a68353e852159a220098e4
parentdac0e5d70e397857ea7d6cf10975de582003a82f (diff)
parentd07e20ea2718c2d460a203f6775aef6cea8ba520 (diff)
downloadnumpy-433e6691113c4656cd939f94da4a837ed08e59a4.tar.gz
Merge pull request #6733 from gerritholl/structured_multidim_masked_array_strrep
BUG/TST: Fix for #6729
-rw-r--r--numpy/ma/core.py2
-rw-r--r--numpy/ma/tests/test_core.py12
2 files changed, 13 insertions, 1 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index b9f7da092..b7ee4a797 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -3695,7 +3695,7 @@ class MaskedArray(ndarray):
if m is nomask:
res = self._data
else:
- if m.shape == ():
+ if m.shape == () and m.itemsize==len(m.dtype):
if m.dtype.names:
m = m.view((bool, len(m.dtype)))
if m.any():
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index e5fdfddb1..4e6a20ad9 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -625,6 +625,18 @@ class TestMaskedArray(TestCase):
control = "[(--, (2, --)) (4, (--, 6.0))]"
assert_equal(str(test), control)
+ # Test 0-d array with multi-dimensional dtype
+ t_2d0 = masked_array(data = (0, [[0.0, 0.0, 0.0],
+ [0.0, 0.0, 0.0]],
+ 0.0),
+ mask = (False, [[True, False, True],
+ [False, False, True]],
+ False),
+ dtype = "int, (2,3)float, float")
+ control = "(0, [[--, 0.0, --], [0.0, 0.0, --]], 0.0)"
+ assert_equal(str(t_2d0), control)
+
+
def test_flatten_structured_array(self):
# Test flatten_structured_array on arrays
# On ndarray