[SciPy-user] Periodic spline interpolation bug / memory error?

Zachary Pincus zpincus at stanford.edu
Wed Mar 15 20:41:20 EST 2006


> I think I found the problem.  For this situation, the estimated for  
> the
> number of knots needed was set to the expected value (but it could  
> need
> more, which it did in your situation).  Then, this error was not  
> handled
> well because the value of n under these conditions was not even being
> set (but was being used to allocate memory).
>
> I committed two fixes to SVN:

Hello again. I just svn up'd my scipy and numpy trees to check this out.

The fix does indeed allow the periodic parametric spline  
interpolation to work. Unfortunately, now it seems to be producing  
wrong results! Unless perhaps I am misunderstanding what the 'per'  
option is supposed to be doing.

Same setup as before:
import numpy, scipy, scipy.interpolate
twopi = numpy.arange(0, 2 * numpy.pi, 0.1)
xs = numpy.cos(twopi)
ys = numpy.sin(twopi)
tck, uout = scipy.interpolate.splprep([xs, ys], u = twopi, per = False)
tck_per, uout = scipy.interpolate.splprep([xs, ys], u = twopi, per =  
True)
# some warning text is printed
out = scipy.interpolate.splev(twopi, tck)
out_per = scipy.interpolate.splev(twopi, tck_per)

Now, 'out' isn't quite right because it wasn't forced to be periodic.  
So instead of a circle, it looks like an alpha:
import Gnuplot
g = Gnuplot.Gnuplot()
g.plot(numpy.transpose(out))
But, 'out_per' is even worse. It seems to be a line, or nearly so:
g.plot(numpy.transpose(out_per))

I'm not sure if this is an error or what... but it seems to be  
somehow wrong, for sure!

Zach




More information about the SciPy-User mailing list