numpy NaN, not surviving pickle/unpickle?

John Ladasky john_ladasky at sbcglobal.net
Sun Sep 13 18:18:19 EDT 2009


Hi Robert,

Thanks for the quick reply.

On Sep 13, 1:22 pm, Robert Kern <robert.k... at gmail.com> wrote:

> The problem is that you are trying to use "is" to compare by Python object
> identity. Except for dtype=object arrays, the object identities of the
> individual elements that you extract from numpy arrays are never guaranteed.
> Usually, they will always be different. You need to use numpy.isnan() to
> determine whether an object is a NaN.

OK, so there's a dedicated function in numpy to handle this.  Thanks!

I tried "x is NaN" after noting the obvious, that any equality or
inequality test involving NaN will return False.

In my leisure time, I would like to dig deeper into the issue of why
object identities are not guaranteed for elements in numpy arrays...
with elements of type "float", at least, I thought this would be
trivial.



More information about the Python-list mailing list