Skip to content

Commit

Permalink
use interpolated univariate spline for cubic spline in interp()
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Jan 19, 2024
1 parent bf58e03 commit 5ac3795
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion larch/math/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from scipy.stats import linregress
from scipy.interpolate import UnivariateSpline
from scipy.interpolate import InterpolatedUnivariateSpline as IUSpline
from scipy.interpolate import interp1d as scipy_interp1d

from .lineshapes import gaussian, lorentzian, voigt
Expand Down Expand Up @@ -151,7 +152,7 @@ def interp(x, y, xnew, kind='linear', fill_value=np.nan, **kws):
coefs = polyfit(x[sel], y[sel], 2)
out[span] = coefs[0] + xnew[span]*(coefs[1] + coefs[2]*xnew[span])
elif kind.startswith('cubic'):
out[span] = UnivariateSpline(x[sel], y[sel], s=0)(xnew[span])
out[span] = IUSpline(x[sel], y[sel])(xnew[span])
return out


Expand Down

0 comments on commit 5ac3795

Please sign in to comment.