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

Method fill_value

numpy/ma/core.py:3723–3761  ·  view source on GitHub ↗

The filling value of the masked array is a scalar. When setting, None will set to a default based on the data type. Examples -------- >>> for dt in [np.int32, np.int64, np.float64, np.complex128]: ... np.ma.array([0, 1], dtype=dt).get_fill_value(

(self)

Source from the content-addressed store, hash-verified

3721
3722 @property
3723 def fill_value(self):
3724 """
3725 The filling value of the masked array is a scalar. When setting, None
3726 will set to a default based on the data type.
3727
3728 Examples
3729 --------
3730 >>> for dt in [np.int32, np.int64, np.float64, np.complex128]:
3731 ... np.ma.array([0, 1], dtype=dt).get_fill_value()
3732 ...
3733 999999
3734 999999
3735 1e+20
3736 (1e+20+0j)
3737
3738 >>> x = np.ma.array([0, 1.], fill_value=-np.inf)
3739 >>> x.fill_value
3740 -inf
3741 >>> x.fill_value = np.pi
3742 >>> x.fill_value
3743 3.1415926535897931 # may vary
3744
3745 Reset to default:
3746
3747 >>> x.fill_value = None
3748 >>> x.fill_value
3749 1e+20
3750
3751 """
3752 if self._fill_value is None:
3753 self._fill_value = _check_fill_value(None, self.dtype)
3754
3755 # Temporary workaround to account for the fact that str and bytes
3756 # scalars cannot be indexed with (), whereas all other numpy
3757 # scalars can. See issues #7259 and #7267.
3758 # The if-block can be removed after #7267 has been fixed.
3759 if isinstance(self._fill_value, ndarray):
3760 return self._fill_value[()]
3761 return self._fill_value
3762
3763 @fill_value.setter
3764 def fill_value(self, value=None):

Callers

nothing calls this directly

Calls 2

_check_fill_valueFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected