8000 MAINT: Remove special casing of 0d in MaskedArray.__str__ · numpy/numpy@91b83ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 91b83ac

Browse files
committed
MAINT: Remove special casing of 0d in MaskedArray.__str__
1 parent 366b14c commit 91b83ac

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

numpy/ma/core.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,30 +3827,13 @@ def __str__(self):
38273827
38283828
"""
38293829
if masked_print_option.enabled():
3830-
f = masked_print_option
3831-
if self is masked:
3832-
return str(f)
3833-
m = self._mask
3834-
if m is nomask:
3830+
mask = self._mask
3831+
if mask is nomask:
38353832
res = self._data
38363833
else:
3837-
if m.shape == () and m.itemsize==len(m.dtype):
3838-
if m.dtype.names:
3839-
m = m.view((bool, len(m.dtype)))
3840-
if m.any():
3841-
return str(tuple((f if _m else _d) for _d, _m in
3842-
zip(self._data.tolist(), m)))
3843-
else:
3844-
return str(self._data)
3845-
elif m:
3846-
return str(f)
3847-
else:
3848-
return str(self._data)
38493834
# convert to object array to make filled work
3850-
names = self.dtype.names
3851-
if names is None:
3835+
if self.dtype.names is None:
38523836
data = self._data
3853-
mask = m
38543837
# For big arrays, to avoid a costly conversion to the
38553838
# object dtype, extract the corners before the conversion.
38563839
print_width = (self._print_width if self.ndim > 1
@@ -3863,11 +3846,11 @@ def __str__(self):
38633846
arr = np.split(mask, (ind, -ind), axis=axis)
38643847
mask = np.concatenate((arr[0], arr[2]), axis=axis)
38653848
res = data.astype("O")
3866-
res.view(ndarray)[mask] = f
3849+
res.view(ndarray)[mask] = masked_print_option
38673850
else:
38683851
rdtype = _replace_dtype_fields(self.dtype, "O")
38693852
res = self._data.astype(rdtype)
3870-
_recursive_printoption(res, m, f)
3853+
_recursive_printoption(res, mask, masked_print_option)
38713854
else:
38723855
res = self.filled(self.fill_value)
38733856
return str(res)

0 commit comments

Comments
 (0)
0