8000 MAINT: Remove hack from gh-7659 for gh-7493 · numpy/numpy@366b14c · GitHub
[go: up one dir, main page]

Skip to content

Commit 366b14c

Browse files
committed
MAINT: Remove hack from gh-7659 for gh-7493
Working with 0d arrays is enough here
1 parent bac743b commit 366b14c

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

numpy/ma/core.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,7 @@ def _recursive_printoption(result, mask, printopt):
24202420
names = result.dtype.names
24212421
for name in names:
24222422
(curdata, curmask) = (result[name], mask[name])
2423-
if curdata.dtype.names:
2423+
if result.dtype[name].names:
24242424
_recursive_printoption(curdata, curmask, printopt)
24252425
else:
24262426
np.copyto(curdata, printopt, where=curmask)
@@ -6004,7 +6004,7 @@ def __new__(self, data, mask=nomask, dtype=None, fill_value=None,
60046004

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

60096009
_data = property(fget=_get_data)
60106010

@@ -6040,19 +6040,13 @@ def __setitem__(self, indx, value):
60406040
def __str__(self):
60416041
m = self._mask
60426042
if m is nomask:
6043-
return self._data.__str__()
6044-
printopt = masked_print_option
6045-
rdtype = _replace_dtype_fields(self._data.dtype, "O")
6046-
6047-
# temporary hack to fix gh-7493. A more permanent fix
6048-
# is proposed in gh-6053, after which the next two
6049-
# lines should be changed to
6050-
# res = np.array([self._data], dtype=rdtype)
6051-
res = np.empty(1, rdtype)
6052-
res[:1] = self._data
6043+
return str(self._data)
60536044

6054-
_recursive_printoption(res, self._mask, printopt)
6055-
return str(res[0])
6045+
rdtype = _replace_dtype_fields(self._data.dtype, "O")
6046+
data_arr = super(mvoid, self)._data
6047+
res = data_arr.astype(rdtype)
6048+
_recursive_printoption(res, self._mask, masked_print_option)
6049+
return str(res)
60566050

60576051
__repr__ = __str__
60586052

0 commit comments

Comments
 (0)
0