[Numpy-discussion] masked_values behaviour

Paul Hobson pmhobson at gmail.com
Fri Dec 15 17:54:27 EST 2017


I think this is a floating point precision issue.

https://docs.python.org/3.6/tutorial/floatingpoint.html

On Fri, Dec 15, 2017 at 1:40 PM, Jesper Larsen <jesper.webmail at gmail.com>
wrote:

> Hi numpy people,
>
> I was just wondering whether this behaviour is intended:
>
> >>> import numpy as np
> >>> np.ma.masked_values(np.array([-32768.0]), np.int16(-32768))
> masked_array(data = [-32768.],
>              mask = False,
>        fill_value = -32768.0)
>
> So the resulting masked array is not masked. On the other hand it is
> masked in the three cases below:
>
> >>> np.ma.masked_values(np.array([-32767.0]), np.int16(-32767))
> masked_array(data = [--],
>              mask = [ True],
>        fill_value = -32767.0)
>
> >>> np.ma.masked_values(np.array([-32768.0]), -32768.0)
> masked_array(data = [--],
>              mask = [ True],
>        fill_value = -32768.0)
>
> >>> np.ma.masked_values(np.array([-32768.0]), -32768)
> masked_array(data = [--],
>              mask = [ True],
>        fill_value = -32768.0)
>
> Best regards,
> Jesper
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20171215/bcf9c480/attachment.html>


More information about the NumPy-Discussion mailing list