numpy.ma.mask_or() function | Python

numpy.ma.mask_or() function combine two masks with the logical_or operator. The result may be a view on m1 or m2 if the other is nomask (i.e. False).

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.

Code #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

[ True  True False  True]

 
Code #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output :

[ True  True False  True]



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.