scipy: `interp1d` behaviour inconsistent with Numpy's?
Scipy interpolator returns nan
if one of the neighbor is a nan
even when interpolation is not actually needed.
This looks inconsistent with Numpy’s behaviour :
>>> import numpy as np
>>> from scipy.interpolate import interp1d
>>> np.interp([0,1,2], xp=[0,1,2], fp=[np.nan,0,1])
array([nan, 0., 1.])
>>> interp1d([0, 1, 2], [np.nan, 0, 1])([0,1,2])
array([nan, nan, 1.])
Is that an expected behaviour ?
Thanks a lot,
Version information :
>>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
1.6.0 1.19.4 sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (13 by maintainers)
Reopening until @mathisc confirms that gh-14601 fixes the original issue or comes up with a fix, as per https://github.com/scipy/scipy/issues/14531#issuecomment-902205813
Yeah, this should keep backwards compatibility, including dtypes
In principle, we can review a PR which changes it for the “linear” kind. Might be a backcompat issue, too — touching interp1d always breaks something for somebody (space bar overheating it is).