Check if the numpy array is masked or not

Is there an easy way to check if a numpy array is masked or not?

I am currently checking if marr is marr or not:

 try: arr = marr.data except: arr = marr 
+5
source share
1 answer

You can use the python isinstance function to check if an object is an instance of a class.

 >>> isinstance(np.ma.array(np.arange(10)),np.ma.MaskedArray) True >>> isinstance(np.arange(10),np.ma.MaskedArray) False 
+8
source

Source: https://habr.com/ru/post/1259302/


All Articles