Duplicate minimal entries in interpolate.interp1d result in nan
See original GitHub issueinterpolate.interp1d returns nan in the following example for me (scipy version is 0.14.0):
In [7]: f = interpolate.interp1d([0, 0, 1], [0, 0, 1], kind='linear')
In [8]: f(0)
/home/jmetzen/.anaconda/lib/python2.7/site-packages/scipy/interpolate/interpolate.py:445: RuntimeWarning: invalid value encountered in true_divide
slope = (y_hi - y_lo) / (x_hi - x_lo)[:, None]
Out[8]: array(nan)
Everything works fine in the case without duplicates:
In [13]: f = interpolate.interp1d([0, 1], [0, 1], kind='linear')
In [14]: f(0)
Out[14]: array(0.0)
Duplicating any other entry besides the minimal one seems to be ok. I guess this is a bug?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Why does interp1d in scipy give a NaN when the first 2 values ...
Your problem is that you are trying to interpolate points that are outside the interval, this causes that scipy.interpolate.interp1d ...
Read more >scipy.interpolate.interp1d — SciPy v1.9.3 Manual
Specifies the axis of y along which to interpolate. Interpolation defaults to the last axis of y. copybool, optional. If True, the class...
Read more >Source code for cooltools.lib.numutils
[docs]def fill_na(arr, value=0, copy=True): """Replaces np.nan entries in an array ... interpolator = scipy.interpolate.interp1d( inds[~isnan], a[~isnan], ...
Read more >mtweb.cs.ucl.ac.uk/mus/lib/python2.6/scipy-0.11.0-...
This class returns a function whose call method uses spline interpolation to ... kind='linear', copy=True, bounds_error=False, fill_value=np.nan): self.x, ...
Read more >brainbox.processing.processing — IBL Library documentation
import numpy as np import pandas as pd from scipy import interpolate from ... See interp1d for possible values, defaults to np.nan :return:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
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
The docs say
Would it make sense to officially deprecate
interp1d
so that it raises a deprecation warning?Edit: never mind, I see that interp1d clones a matlab function, so it will live forever.
We won’t be deprecating
interp1d
any time soon it seems. Handling of duplicate values is also best left as is, cf. gh-9886. Looks like there’s not much to do here, thus closing. Thanks @jmetzen, all.