[Scipy-svn] r2762 - trunk/Lib/interpolate

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Feb 26 07:26:07 EST 2007


Author: jtravs
Date: 2007-02-26 06:26:04 -0600 (Mon, 26 Feb 2007)
New Revision: 2762

Modified:
   trunk/Lib/interpolate/fitpack.py
Log:
Submit fix for ticket #379


Modified: trunk/Lib/interpolate/fitpack.py
===================================================================
--- trunk/Lib/interpolate/fitpack.py	2007-02-26 03:21:38 UTC (rev 2761)
+++ trunk/Lib/interpolate/fitpack.py	2007-02-26 12:26:04 UTC (rev 2762)
@@ -252,7 +252,7 @@
 
 _curfit_cache = {'t': array([],float), 'wrk': array([],float),
                  'iwrk':array([],int32)}
-def splrep(x,y,w=None,xb=None,xe=None,k=3,task=0,s=1e-3,t=None,
+def splrep(x,y,w=None,xb=None,xe=None,k=3,task=0,s=None,t=None,
            full_output=0,per=0,quiet=1):
     """Find the B-spline representation of 1-D curve.
 
@@ -292,7 +292,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.
@@ -335,8 +336,12 @@
         _curfit_cache = {}
     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)):
         raise TypeError, 'Lengths of the first three arguments (x,y,w) must be equal'
@@ -346,7 +351,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:
         task = -1
     if task == -1:




More information about the Scipy-svn mailing list