[Numpy-discussion] converting nan to an integer
joep
josef.pktd at gmail.com
Sat Oct 4 10:31:21 EDT 2008
Why does converting nan to an integer not throw an exception (as with
inf), instead numpy silently replaces nan by zero?
>>> inti = np.array([0,1,2])
>>> inti.dtype
dtype('int32')
>>> inti[1] = np.inf
Traceback (most recent call last):
File "<pyshell#34>", line 1, in ?
inti[1] = np.inf
OverflowError: cannot convert float infinity to long
>>> inti[1] = np.nan
>>> inti
array([0, 0, 2])
This is based on an example in numpy.stats.distribution.py
Josef
More information about the NumPy-Discussion
mailing list