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
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to