[Numpy-discussion] MA bug or feature?

Pierre GM pgmdevlist at mailcan.com
Thu Jun 22 14:15:15 CDT 2006

On Wednesday 21 June 2006 22:01, Michael Sorich wrote:
> I was setting the fill_value as 'NA' when constructing the array so
> the masked values would be printed as 'NA'. It is not a big deal to
> avoid doing this.

You can use masked_print_option, as illustrated below, without using a 
fill_value incompatible with your data type.

>>>import numpy.core.ma as MA
>>>X = MA.array([1,2,3],maks=[0,1,0])
>>>print X
[1 -- 3]
>>>print X
[1 N/A 3]

> Nevertheless, the differences between a masked array with a boolean
> mask and a mask of booleans have caused me trouble before. Especially
> when there are hidden in-place conversions of a mask which is a array
> of False to a mask which is False. e.g.

OK, I'm still using 0.9.8 and I can't help you with this one. In that version,  
N.asarray transforms the MA into a ndarray, so you lose the mask.

But I wonder: if none of your values are masked, the natural behavior would be 
to have `data.mask==nomask`, which speeds up things a bit. This gain of time 
is why I was suggesting that `mask` would be forced to `nomask` at the 
creation, if `mask.any()==False`.

Could you give me some examples of cases where you need the mask to stay as an 
array of False ?
If you need to access the mask as an array, you can always use 

More information about the Numpy-discussion mailing list