[Numpy-discussion] Question on numpy.ma.masked_values
Gökhan Sever
gokhansever@gmail....
Thu Mar 15 14:41:16 CDT 2012
Submitted the ticket at http://projects.scipy.org/numpy/ticket/2082
On Thu, Mar 15, 2012 at 1:24 PM, Gökhan Sever <gokhansever@gmail.com> wrote:
>
>
> On Thu, Mar 15, 2012 at 1:12 PM, Pierre GM <pgmdevlist@gmail.com> wrote:
>
>> Ciao Gökhan,
>> AFAIR, shrink is used only to force a collapse of a mask full of False,
>> not to force the creation of such a mask.
>> Now, it should work as you expected, meaning that it needs to be fixed.
>> Could you open a ticket? And put me in copy, just in case.
>> Anyhow:
>> Your trick is a tad dangerous, as it erases the previous mask. I'd prefer
>> to create x w/ a full mask, then use masked_values w/ shrink=False... Now,
>> if you're sure there's x= no masked values, go for it.
>> Cheers
>>
>> This condition checking should make it stronger:
>
> I7 x = np.array([1, 1.1, 2, 1.1, 3])
>
> I8 y = np.ma.masked_values(x, 1.5)
>
> I9 if y.mask == False:
> y.mask = np.zeros(len(x), dtype=np.bool)*True
> ...:
>
> I10 y.mask
> O10 array([False, False, False, False, False], dtype=bool)
>
> I11 y
> O11
> masked_array(data = [1.0 1.1 2.0 1.1 3.0],
> mask = [False False False False False],
> fill_value = 1.5)
>
> How do you create "x w/ a full mask"?
>
> --
> Gökhan
>
--
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120315/19eb6674/attachment.html
More information about the NumPy-Discussion
mailing list