Skip to content

Commit

Permalink
MAINT: Remove hack from numpygh-7659 for numpygh-7493
Browse files Browse the repository at this point in the history
Working with 0d arrays is enough here
  • Loading branch information
eric-wieser committed Sep 25, 2017
1 parent bac743b commit 366b14c
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2420,7 +2420,7 @@ def _recursive_printoption(result, mask, printopt):
names = result.dtype.names
for name in names:
(curdata, curmask) = (result[name], mask[name])
if curdata.dtype.names:
if result.dtype[name].names:
_recursive_printoption(curdata, curmask, printopt)
else:
np.copyto(curdata, printopt, where=curmask)
Expand Down Expand Up @@ -6004,7 +6004,7 @@ def __new__(self, data, mask=nomask, dtype=None, fill_value=None,

def _get_data(self):
# Make sure that the _data part is a np.void
return self.view(ndarray)[()]
return super(mvoid, self)._data[()]

_data = property(fget=_get_data)

Expand Down Expand Up @@ -6040,19 +6040,13 @@ def __setitem__(self, indx, value):
def __str__(self):
m = self._mask
if m is nomask:
return self._data.__str__()
printopt = masked_print_option
rdtype = _replace_dtype_fields(self._data.dtype, "O")

# temporary hack to fix gh-7493. A more permanent fix
# is proposed in gh-6053, after which the next two
# lines should be changed to
# res = np.array([self._data], dtype=rdtype)
res = np.empty(1, rdtype)
res[:1] = self._data
return str(self._data)

_recursive_printoption(res, self._mask, printopt)
return str(res[0])
rdtype = _replace_dtype_fields(self._data.dtype, "O")
data_arr = super(mvoid, self)._data
res = data_arr.astype(rdtype)
_recursive_printoption(res, self._mask, masked_print_option)
return str(res)

__repr__ = __str__

Expand Down

0 comments on commit 366b14c

Please sign in to comment.