thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

interp(nan, ...) should yield nan (Trac #2149) #5941

Open numpy-gitbot opened 12 years ago

numpy-gitbot commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/2149 on 2012-05-31 by trac user ehiggs, assigned to unknown.

Passing nan to the first argument of interp appears to return the first element of fp. This isn't a meaningful value and can silently corrupt data since nan went in and undetectable garbage came out.

>>> import numpy as np
>>> np.interp(1, [-10, 10], [-2, 2])
0.20000000000000018
>>> np.interp(np.nan, [-10, 10], [-2, 2])
-2.0
>>> np.interp([np.nan, 1], [-10, 10], [-2, 2])
array([-2. ,  0.2])

This -2.0 is not a meaningful answer. The interpolation of a nan value should probably also be nan.

Thanks