-
numpy.ma.set_fill_value(a, fill_value)
[source] -
Set the filling value of a, if a is a masked array.
This function changes the fill value of the masked array
a
in place. Ifa
is not a masked array, the function returns silently, without doing anything.Parameters: a : array_like
Input array.
fill_value : dtype
Filling value. A consistency test is performed to make sure the value is compatible with the dtype of
a
.Returns: None
Nothing returned by this function.
See also
-
maximum_fill_value
- Return the default fill value for a dtype.
-
MaskedArray.fill_value
- Return current fill value.
-
MaskedArray.set_fill_value
- Equivalent method.
Examples
1234567891011121314>>>
import
numpy.ma as ma
>>> a
=
np.arange(
5
)
>>> a
array([
0
,
1
,
2
,
3
,
4
])
>>> a
=
ma.masked_where(a <
3
, a)
>>> a
masked_array(data
=
[
-
-
-
-
-
-
3
4
],
mask
=
[
True
True
True
False
False
],
fill_value
=
999999
)
>>> ma.set_fill_value(a,
-
999
)
>>> a
masked_array(data
=
[
-
-
-
-
-
-
3
4
],
mask
=
[
True
True
True
False
False
],
fill_value
=
-
999
)
Nothing happens if
a
is not a masked array.123456789101112>>> a
=
range
(
5
)
>>> a
[
0
,
1
,
2
,
3
,
4
]
>>> ma.set_fill_value(a,
100
)
>>> a
[
0
,
1
,
2
,
3
,
4
]
>>> a
=
np.arange(
5
)
>>> a
array([
0
,
1
,
2
,
3
,
4
])
>>> ma.set_fill_value(a,
100
)
>>> a
array([
0
,
1
,
2
,
3
,
4
])
-
numpy.ma.set_fill_value()

2025-01-10 15:47:30
Please login to continue.