[Scipy-svn] r2763 - trunk/Lib/sandbox/spline

scipy-svn@scip... scipy-svn@scip...
Mon Feb 26 06:42:46 CST 2007

```Author: jtravs
Date: 2007-02-26 06:42:43 -0600 (Mon, 26 Feb 2007)
New Revision: 2763

Modified:
trunk/Lib/sandbox/spline/fitpack.py
Log:
Update sandbox.spline to correspond to recent changes to interpolate.

Modified: trunk/Lib/sandbox/spline/fitpack.py
===================================================================
--- trunk/Lib/sandbox/spline/fitpack.py	2007-02-26 12:26:04 UTC (rev 2762)
+++ trunk/Lib/sandbox/spline/fitpack.py	2007-02-26 12:42:43 UTC (rev 2763)
@@ -266,7 +266,7 @@
_splrep_cache = {}
_percur_cache = {}

full_output=0,per=0,quiet=1):
"""Find the B-spline representation of 1-D curve.

@@ -304,7 +304,8 @@
weights represent the inverse of the standard-deviation of y, then a
good s value should be found in the range (m-sqrt(2*m),m+sqrt(2*m))
where m is the number of datapoints in x, y, and w.
-           default : s=m-sqrt(2*m)
+           default : s = m-sqrt(2*m) if weights are supplied.
+                     s = 0.0 (interpolating) if no weights are supplied.
t -- The knots needed for task=-1.  If given then task is automatically
set to -1.
full_output -- If non-zero, then return optional outputs.
@@ -342,8 +343,12 @@
"""
x,y=map(myasarray,[x,y])
m=len(x)
-    if w is None: w=ones(m,float)
-    else: w=myasarray(w)
+    if w is None:
+        w=ones(m,float)
+        if s is None: s = 0.0
+    else:
+        w=myasarray(w)
+        if s is None: s = m-sqrt(2*m)
if not len(w) == m:
raise TypeError,' len(w)=%d is not equal to m=%d'%(len(w),m)
if (m != len(y)) or (m != len(w)):
@@ -356,7 +361,6 @@
if xb is None: xb=x[0]
if xe is None: xe=x[-1]
if not (-1<=task<=1): raise TypeError, 'task must be either -1,0, or 1'
-    if s is None: s = m-sqrt(2*m)
if t is not None:
@@ -381,21 +385,22 @@
_percur_cache['wrk']=wrk
_percur_cache['iwrk']=iwrk
_percur_cache['n']=n
-        spl = spline.UnivariateSpline(x,y,w,[xb,xe],k=k,s=s)
-        try:
-            spl = _splrep_cache['spl']
-        except KeyError:
-        spl.set_smoothing_factor(s)
-        t = t[where(t>xb)]
-        t = t[where(t<xe)]
-        spl = spline.LSQUnivariateSpline(x,y,t,w,[xb,xe],k=k)
-        _splrep_cache['spl'] = spl
-    x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier = spl._data
+    else:
+            spl = spline.UnivariateSpline(x,y,w,[xb,xe],k=k,s=s)
+            try:
+                spl = _splrep_cache['spl']
+            except KeyError:
+            spl.set_smoothing_factor(s)
+            t = t[where(t>xb)]
+            t = t[where(t<xe)]
+            spl = spline.LSQUnivariateSpline(x,y,t,w,[xb,xe],k=k)