diff options
| author | Eric Wieser <wieser.eric@gmail.com> | 2017-09-25 09:22:25 -0700 |
|---|---|---|
| committer | Eric Wieser <wieser.eric@gmail.com> | 2017-09-25 21:57:51 -0700 |
| commit | 25c808cc2e359acf9688d33c24f4c6c51938356f (patch) | |
| tree | d25a0078a8e677bc22cd981671fda24a51e63bc1 /numpy/ma/core.py | |
| parent | 91b83ac6a9477bfb469e270b6e8634b597a3d1ac (diff) | |
| download | numpy-25c808cc2e359acf9688d33c24f4c6c51938356f.tar.gz | |
MAINT: Remove special casing of structured dtypes in MaskedArray.__str__
This means that large void arrays are now truncated as they are for other types, for speed.
Diffstat (limited to 'numpy/ma/core.py')
| -rw-r--r-- | numpy/ma/core.py | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index de72d2080..1f70d78e0 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2418,12 +2418,13 @@ def _recursive_printoption(result, mask, printopt): """ names = result.dtype.names - for name in names: - (curdata, curmask) = (result[name], mask[name]) - if result.dtype[name].names: + if names: + for name in names: + curdata = result[name] + curmask = mask[name] _recursive_printoption(curdata, curmask, printopt) - else: - np.copyto(curdata, printopt, where=curmask) + else: + np.copyto(result, printopt, where=mask) return _print_templates = dict(long_std="""\ @@ -3832,25 +3833,22 @@ class MaskedArray(ndarray): res = self._data else: # convert to object array to make filled work - if self.dtype.names is None: - data = self._data - # For big arrays, to avoid a costly conversion to the - # object dtype, extract the corners before the conversion. - print_width = (self._print_width if self.ndim > 1 - else self._print_width_1d) - for axis in range(self.ndim): - if data.shape[axis] > print_width: - ind = print_width // 2 - arr = np.split(data, (ind, -ind), axis=axis) - data = np.concatenate((arr[0], arr[2]), axis=axis) - arr = np.split(mask, (ind, -ind), axis=axis) - mask = np.concatenate((arr[0], arr[2]), axis=axis) - res = data.astype("O") - res.view(ndarray)[mask] = masked_print_option - else: - rdtype = _replace_dtype_fields(self.dtype, "O") - res = self._data.astype(rdtype) - _recursive_printoption(res, mask, masked_print_option) + data = self._data + # For big arrays, to avoid a costly conversion to the + # object dtype, extract the corners before the conversion. + print_width = (self._print_width if self.ndim > 1 + else self._print_width_1d) + for axis in range(self.ndim): + if data.shape[axis] > print_width: + ind = print_width // 2 + arr = np.split(data, (ind, -ind), axis=axis) + data = np.concatenate((arr[0], arr[2]), axis=axis) + arr = np.split(mask, (ind, -ind), axis=axis) + mask = np.concatenate((arr[0], arr[2]), axis=axis) + + rdtype = _replace_dtype_fields(self.dtype, "O") + res = data.astype(rdtype) + _recursive_printoption(res, mask, masked_print_option) else: res = self.filled(self.fill_value) return str(res) |
