`interp1d` behaviour inconsistent with Numpy's?
See original GitHub issueScipy 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)
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (13 by maintainers)
Top Results From Across the Web
Interpolation behaviour inconsistent with numpy? · Issue #5664
Hey all, When running dataset.interp(time=dataset.time) fills with np.nan if one of the neighbor is a np.nan even when interpolation is not ...
Read more >Scipys interp1d and infinities - Stack Overflow
When interpolating linearly with scipy.interpolate.interp1d I encounter the following behaviour: from ...
Read more >scipy.interpolate.interp1d — SciPy v1.9.3 Manual
An object-oriented wrapper of the FITPACK routines. Calling interp1d with NaNs present in input values results in undefined behaviour. Input values x and...
Read more >Why is the behavior when assigning to values inconsistent?
[Solved]-Why is the behavior when assigning to values inconsistent?-numpy ... Why does interp1d in scipy give a NaN when the first 2 values...
Read more >Scipy 2d Interpolation - Accademia e sartoria le filatrici
How to do two dimensional interpolation using SciPy in python. ... SciPy. import numpy as np import scipy. interpolate import interp1d f1 =...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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