[Numpy-discussion] behavior of masked arrays

Giorgio F. Gilestro giorgio@gilestro...
Fri Mar 7 08:56:59 CST 2008


Hi Everybody,
I have some arrays that sometimes need to have some of their values 
masked away or, simply said, not considered during manipulation.
I tried to fulfill my purposes using both NaNs and MaskedArray but 
neither of them really helped completely.

Let's give an example:

from numpy import *
import scipy

a = array(arange(40).reshape(5,8), dtype=float32)
b = array(arange(40,80).reshape(5,8), dtype=float32)
a[1,1] = NaN

tt, ttp = scipy.stats.ttest_ind(a,b,axis=0)

c = numpy.ma.masked_array(a, mask=isnan(a))
tt1, ttp1 = scipy.stats.ttest_ind(c,b,axis=0)

print (ttp == ttp1).all()

will return True.

My understanding is that only a few functions will be able to properly 
use MA during execution. Is this correct or am I missing something here?

Thanks


More information about the Numpy-discussion mailing list