[SciPy-User] scipy interpolate.interp1d spline slowness

Jaidev Deshpande deshpande.jaidev at gmail.com
Wed Dec 12 17:22:10 EST 2012


---------- Forwarded message ----------
From: Wolfgang Kerzendorf <wkerzendorf at gmail.com>
Date: Thu, Dec 13, 2012 at 3:38 AM
Subject: [SciPy-User] scipy interpolate.interp1d spline slowness
To: SciPy Users List <scipy-user at scipy.org>


Hello Scipyers,

I've just stumbled across a problem with interpolate.interp1d:
-------------
import numpy as np
from scipy import interpolate
x = arange(1000)
y =  y = np.random.random_integers(0, 900, 1000)

%timeit interp = interpolate.interp1d(x, y, kind='cubic')
1 loops, best of 3: 3.63 s per loop
#the call for the interpolation is really quick afterwards (a couple ms)

tck = interpolate.splrep(x, y, s=0)
%timeit interpolate.splev(x_new, tck, der=0)
100 loops, best of 3: 5.51 ms per loop

------
I do understand that these are different spline interpolations (but
that's as far as my knowledge goes). I was just annoyed at the person
saying: Ah, you see python is slow - which it is not as shown by the
second scipy command.

Would it be possible to switch the spline interpolator used in
interpolate.interp1d to the B-Splines, or to give an option to switch
between different spline interpolators (maybe with a warning: slow).

Hi,

I don't know how much I can help, but I've noticed that
scipy.interpolate.splrep and scipy.interpolate.splev are slightly
faster than interp1d.

It should suffice for cubic splines.

HTH

Ah - a last question: Why don't you  use the issues tab on the github page?

Thanks in advance,
   Wolfgang
_______________________________________________
SciPy-User mailing list
SciPy-User at scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user


--
JD



More information about the SciPy-User mailing list