ValueError: cannot convert float to NaN to integer
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? BTW, is there a way to determine the svn revision number of numpy when installed from binary?
On Wed, Jul 22, 2009 at 13:35, Keith Goodman
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
On Wed, Jul 22, 2009 at 11:51 AM, Robert Kern
On Wed, Jul 22, 2009 at 13:35, Keith Goodman
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.
The same error shows up when running the numpy unit tests with python 2.6 (but not with python 2.5): ====================================================================== ERROR: Tests the min/max functions with explicit outputs ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/numpy/ma/tests/test_core.py", line 699, in test_minmax_funcs_with_output result = npfunc(xm,axis=0,out=nout) File "/usr/lib/python2.6/dist-packages/numpy/core/fromnumeric.py", line 1569, in amin return amin(axis, out) File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 3119, in min np.putmask(out, newmask, np.nan) ValueError: cannot convert float NaN to integer
participants (2)
-
Keith Goodman
-
Robert Kern