diff options
author | Gerrit Holl <g.holl@reading.ac.uk> | 2015-11-26 12:01:15 +0000 |
---|---|---|
committer | Gerrit Holl <g.holl@reading.ac.uk> | 2015-12-01 14:06:04 +0000 |
commit | d07e20ea2718c2d460a203f6775aef6cea8ba520 (patch) | |
tree | aa1224ac2147fdca63a68353e852159a220098e4 | |
parent | dac0e5d70e397857ea7d6cf10975de582003a82f (diff) | |
download | numpy-d07e20ea2718c2d460a203f6775aef6cea8ba520.tar.gz |
BUG/TST: Fix for #6729
Fix representation of a structured masked array with dimension zero.
The effect of representing a masked array with dimension zero is now
similar to respresenting an mvoid. This commit fixes #6729.
-rw-r--r-- | numpy/ma/core.py | 2 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 12 |
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 |