[Numpy-discussion] ValueError: cannot convert float to NaN to integer

Robert Kern robert.kern@gmail....
Wed Jul 22 13:51:37 CDT 2009


On Wed, Jul 22, 2009 at 13:35, Keith Goodman<kwgoodman@gmail.com> wrote:
> On Ubuntu 9.04, python 2.6.2, numpy 1.2.1 this gives a ValueError:
>
> x = np.array([1,2,3])
> x[0] = np.nan
> ValueError: cannot convert float to NaN to integer
>
> But on Debian squeeze, python 2.5.4, numpy 1.2.1 the assignment works
> (well, the float nan is convert to the int 0):
>
> x[0] = np.nan
> x
>   array([0,1,2])
>
> The numpy version numbers are the same. Is this a python issue?

Probably. They rationalized a bunch of float behavior in Python 2.6,
and this may be a consequence of that. grep the Python sources for
that error message, or parts of it, to try to track down where it
comes from.

> BTW, is there a way to determine the svn revision number of numpy when
> installed from binary?

Not reliably, I don't think.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list