MCPcopy Create free account
hub / github.com/numpy/numpy / _insert_masked_print

Method _insert_masked_print

numpy/ma/core.py:3965–3994  ·  view source on GitHub ↗

Replace masked values with masked_print_option, casting all innermost dtypes to object.

(self)

Source from the content-addressed store, hash-verified

3963 return _new
3964
3965 def _insert_masked_print(self):
3966 """
3967 Replace masked values with masked_print_option, casting all innermost
3968 dtypes to object.
3969 """
3970 if masked_print_option.enabled():
3971 mask = self._mask
3972 if mask is nomask:
3973 res = self._data
3974 else:
3975 # convert to object array to make filled work
3976 data = self._data
3977 # For big arrays, to avoid a costly conversion to the
3978 # object dtype, extract the corners before the conversion.
3979 print_width = (self._print_width if self.ndim > 1
3980 else self._print_width_1d)
3981 for axis in range(self.ndim):
3982 if data.shape[axis] > print_width:
3983 ind = print_width // 2
3984 arr = np.split(data, (ind, -ind), axis=axis)
3985 data = np.concatenate((arr[0], arr[2]), axis=axis)
3986 arr = np.split(mask, (ind, -ind), axis=axis)
3987 mask = np.concatenate((arr[0], arr[2]), axis=axis)
3988
3989 rdtype = _replace_dtype_fields(self.dtype, "O")
3990 res = data.astype(rdtype)
3991 _recursive_printoption(res, mask, masked_print_option)
3992 else:
3993 res = self.filled(self.fill_value)
3994 return res
3995
3996 def __str__(self):
3997 return str(self._insert_masked_print())

Callers 2

__str__Method · 0.95
__repr__Method · 0.95

Calls 6

filledMethod · 0.95
_replace_dtype_fieldsFunction · 0.85
_recursive_printoptionFunction · 0.85
enabledMethod · 0.80
astypeMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected