[SciPy-user] Ols for np.arrays and masked arrays

Pierre GM pgmdevlist@gmail....
Fri Jan 16 20:27:58 CST 2009

> What's the best way of unmasking a single masked element in a masked  
> array?
> y.data[i] = 5
> y.mask[i] = False
> Is there an ma.unmask(y[i],5)  ?

Nope, but that's an idea.

Meanwhile, the easiest (and recommended way) is to do:
y[i] = 5
That way, you change the data and the mask at the same time. That  
works as long as the mask is soft (which it is, by default. To harden  
a mask, viz, to prevent masked data to be unmasked, you need to really  
want to).

If you just want to unmask without changing the value, you need to  
check whether you have a mask which is not no.mask, and change it by  
y.mask[i] = False.

Check the docs on the svn site, you'll find the draft documentation  
for numpy.ma under "maskedarray.html". You may have to build the doc  
with Sphinx, but that shouldn't be a problem.

> It's becoming clearer how this can work.

It's quite straightforward, don't worry.

More information about the SciPy-user mailing list