numpy.ma.make_mask_none()函数| Python
numpy.ma.make_mask_none()
函数返回给定形状的布尔掩码,用 False 填充。
此函数返回一个所有条目为 False 的布尔 ndarray,可用于常见的掩码操作。如果指定了复杂的 dtype,则将每个字段的类型转换为布尔类型。
Syntax : numpy.ma.make_mask_none(newshape, dtype = None)
Parameters :
newshape : [tuple] A tuple indicating the shape of the mask.
dtype : [{None, dtype}, optional] By default, the dtype is None. Otherwise, use a new datatype with the same fields as dtype, converted to boolean types.
Return : [ndarray] An ndarray of appropriate shape and dtype, filled with False.
代码#1:
# Python program explaining
# numpy.ma.make_mask_none() function
# importing numpy as geek
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
gfg = ma.make_mask_none(4)
print (gfg)
输出 :
[False False False False]
代码#2:
# Python program explaining
# numpy.ma.make_mask_none() function
# importing numpy as geek
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
gfg = ma.make_mask_none(4, dtype = None)
print (gfg)
输出 :
[False False False False]