-
numpy.ma.is_mask(m)
[source] -
Return True if m is a valid, standard mask.
This function does not check the contents of the input, only that the type is MaskType. In particular, this function returns False if the mask has a flexible dtype.
Parameters: m : array_like
Array to test.
Returns: result : bool
True if
m.dtype.type
is MaskType, False otherwise.See also
-
isMaskedArray
- Test whether input is an instance of MaskedArray.
Examples
12345678910>>>
import
numpy.ma as ma
>>> m
=
ma.masked_equal([
0
,
1
,
0
,
2
,
3
],
0
)
>>> m
masked_array(data
=
[
-
-
1
-
-
2
3
],
mask
=
[
True
False
True
False
False
],
fill_value
=
999999
)
>>> ma.is_mask(m)
False
>>> ma.is_mask(m.mask)
True
Input must be an ndarray (or have similar attributes) for it to be considered a valid mask.
12345678>>> m
=
[
False
,
True
,
False
]
>>> ma.is_mask(m)
False
>>> m
=
np.array([
False
,
True
,
False
])
>>> m
array([
False
,
True
,
False
], dtype
=
bool
)
>>> ma.is_mask(m)
True
Arrays with complex dtypes don?t return True.
1234567891011>>> dtype
=
np.dtype({
'names'
:[
'monty'
,
'pithon'
],
'formats'
:[np.
bool
, np.
bool
]})
>>> dtype
dtype([(
'monty'
,
'|b1'
), (
'pithon'
,
'|b1'
)])
>>> m
=
np.array([(
True
,
False
), (
False
,
True
), (
True
,
False
)],
dtype
=
dtype)
>>> m
array([(
True
,
False
), (
False
,
True
), (
True
,
False
)],
dtype
=
[(
'monty'
,
'|b1'
), (
'pithon'
,
'|b1'
)])
>>> ma.is_mask(m)
False
-
numpy.ma.is_mask()

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