[Numpy-discussion] Warning: converting a masked element to nan

Pierre GM pgmdevlist@gmail....
Wed Apr 23 02:59:12 CDT 2008

As a generic rule, this warning is output when the masked value 
(numpy.ma.masked) has to be converted to a float: in that case, a NaN is 
returned. Now, the exact reason why the masked value has to be converted is 
specific to your problem. A simple example of when this warning occurs would 
help to give you a detailed answer. 
Note that in the previous version (numpy.oldnumeric.ma), an exception was 
raised instead of a warning. I thought it was a bit too drastic.

> Does
> it mean that numpy.ma is converting an element of the data part of the
> MA to NaN, on it's own? 

No, it shouldn't affect the data part.

> Or does it mean that I 
> deliberatly have changed a data element to NaN, and if so, why on earth
> should I be warned for that? I think it is pretty normal to be able to
> create NaN's in my array... Or does it mean yet something else?

Take it as a note-to-self: somewhere down the line, a masked value had to be 
converted to a float, not a 0d array

> And, also important: how can I avoid this (not suppress, but what should
> I stop doing that currently triggers this warning)?

Once again, that depends, and I;m sorry I can be more specific than that: I 
don't have a particular example in mind...

More information about the Numpy-discussion mailing list