MCPcopy
hub / github.com/numpy/numpy / _insert_masked_print

Method _insert_masked_print

numpy/ma/core.py:4047–4076  ·  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

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())

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
splitMethod · 0.80
astypeMethod · 0.80

Tested by

no test coverage detected