Skip to content

Commit

Permalink
BUG/TST: Fix for #6729
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gerritholl committed Dec 1, 2015
1 parent dac0e5d commit d07e20e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/ma/core.py
Expand Up @@ -3695,7 +3695,7 @@ def __str__(self):
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():
Expand Down
12 changes: 12 additions & 0 deletions numpy/ma/tests/test_core.py
Expand Up @@ -625,6 +625,18 @@ def test_fancy_printoptions(self):
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
Expand Down

0 comments on commit d07e20e

Please sign in to comment.