Thanks Pierre.
It's a good idea to always use
a[(a<5).filled(False)] = 2
I don't understand very well the underlying structure but it's good to know
some.
Chao
2012/4/12 Pierre GM
> Ciao Chao,
>
> That known quirk deserves to be better documented, I agree.
>
> There's a simple explanation for
Ciao Chao,
That known quirk deserves to be better documented, I agree.
There's a simple explanation for this behavior:
Because `a` is a masked array, `(a < 5)` is also a masked array with
dtype=np.bool, and whose mask is the same as `a`'s. In your example,
that's:
masked_array(data = [-- -- -- Tr
Dear all numpy users,
I am using numpy 1.6.1
I find that if you want to change some member values in a masked array
according to some conditional selection.
suppose a is a masked array, you want to change all value below zero to
zero.
you must always use
a[np.nonzero(a<0)]=0
rather than a[a<0]=