numpy.ma.mask_or()函数| Python
numpy.ma.mask_or()
函数将两个掩码与 logical_or运算符组合在一起。如果另一个是 nomask(即 False),则结果可能是 m1 或 m2 上的视图。
Syntax : numpy.ma.mask_or(m1, m2, copy = False, shrink = True)
Parameters :
m1, m2 : [ array_like] Input masks.
copy : [bool, optional] If copy is False and one of the inputs is nomask, return a view of the other input mask. Defaults to False
shrink : [bool, optional] Whether to shrink the output to nomask if all its values are False. Defaults to True.
Return : The result masks values that are masked in either m1 or m2.
代码#1:
# Python program explaining
# numpy.ma.mask_or() function
# importing numpy as geek
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
m1 = geek.ma.make_mask([1, 1, 0, 1])
m2 = geek.ma.make_mask([1, 0, 0, 0])
gfg = geek.ma.mask_or(m1, m2)
print (gfg)
输出 :
[ True True False True]
代码#2:
# Python program explaining
# numpy.ma.mask_or() function
# importing numpy as geek
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
m1 = geek.ma.make_mask([1, 0, 0, 0])
m2 = geek.ma.make_mask([1, 1, 0, 1])
gfg = geek.ma.mask_or(m1, m2)
print (gfg)
输出 :
[ True True False True]