Replace masked values with masked_print_option, casting all innermost dtypes to object.
(self)
| 4045 | return _new |
| 4046 | |
| 4047 | def _insert_masked_print(self): |
| 4048 | """ |
| 4049 | Replace masked values with masked_print_option, casting all innermost |
| 4050 | dtypes to object. |
| 4051 | """ |
| 4052 | if masked_print_option.enabled(): |
| 4053 | mask = self._mask |
| 4054 | if mask is nomask: |
| 4055 | res = self._data |
| 4056 | else: |
| 4057 | # convert to object array to make filled work |
| 4058 | data = self._data |
| 4059 | # For big arrays, to avoid a costly conversion to the |
| 4060 | # object dtype, extract the corners before the conversion. |
| 4061 | print_width = (self._print_width if self.ndim > 1 |
| 4062 | else self._print_width_1d) |
| 4063 | for axis in range(self.ndim): |
| 4064 | if data.shape[axis] > print_width: |
| 4065 | ind = print_width // 2 |
| 4066 | arr = np.split(data, (ind, -ind), axis=axis) |
| 4067 | data = np.concatenate((arr[0], arr[2]), axis=axis) |
| 4068 | arr = np.split(mask, (ind, -ind), axis=axis) |
| 4069 | mask = np.concatenate((arr[0], arr[2]), axis=axis) |
| 4070 | |
| 4071 | rdtype = _replace_dtype_fields(self.dtype, "O") |
| 4072 | res = data.astype(rdtype) |
| 4073 | _recursive_printoption(res, mask, masked_print_option) |
| 4074 | else: |
| 4075 | res = self.filled(self.fill_value) |
| 4076 | return res |
| 4077 | |
| 4078 | def __str__(self): |
| 4079 | return str(self._insert_masked_print()) |
no test coverage detected