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

scipy-svn@scip... scipy-svn@scip...
Wed Aug 15 01:04:44 CDT 2007


Author: oliphant
Date: 2007-08-15 01:04:30 -0500 (Wed, 15 Aug 2007)
New Revision: 3244

Modified:
   trunk/Lib/interpolate/interpolate.py
Log:
Fix interpolate.interp1d so that it works for higher order splines.

Modified: trunk/Lib/interpolate/interpolate.py
===================================================================
--- trunk/Lib/interpolate/interpolate.py	2007-08-15 05:44:07 UTC (rev 3243)
+++ trunk/Lib/interpolate/interpolate.py	2007-08-15 06:04:30 UTC (rev 3244)
@@ -197,16 +197,15 @@
         self.bounds_error = bounds_error
         self.fill_value = fill_value
 
-
-        if isinstance(kind, int):
-            kind = {0:'zero',
-                    1:'slinear',
-                    2:'quadratic',
-                    3:'cubic'}.get(kind,'none')
-
-        if kind not in ['zero', 'linear', 'slinear', 'quadratic', 'cubic']:
-            raise NotImplementedError("%d is unsupported: Use fitpack "\
-                                      "routines for other types.")
+        if kind in ['zero', 'slinear', 'quadratic', 'cubic']:
+            order = {'zero':0,'slinear':1,'quadratic':2, 'cubic':3}[kind]
+            kind = 'spline'
+        elif isinstance(kind, int):
+            order = kind
+            kind = 'spline'
+        elif kind != 'linear':
+            raise NotImplementedError("%s is unsupported: Use fitpack "\
+                                      "routines for other types." % kind)
         x = array(x, copy=self.copy)
         y = array(y, copy=self.copy)
 
@@ -228,7 +227,6 @@
             self._call = self._call_linear
         else:
             oriented_y = y.swapaxes(0, axis)
-            order = {'zero':0,'slinear':1,'quadratic':2, 'cubic':3}[kind]
             minval = order + 1
             len_y = oriented_y.shape[0]
             self._call = self._call_spline
@@ -275,7 +273,7 @@
         return y_new
 
     def _call_spline(self, x_new):
-        x_new = asarray(x_new)
+        x_new =np.asarray(x_new)
         result = spleval(self._spline,x_new.ravel())
         return result.reshape(x_new.shape+result.shape[1:])
 
@@ -716,7 +714,7 @@
     res = np.empty(xx.shape + sh)
     for index in np.ndindex(*sh):
         sl = (slice(None),)+index
-        res[sl] = _fitpack._bspleval(xx,xk,cvals[sl],k,deriv)
+        res[sl] = _fitpack._bspleval(xx,xj,cvals[sl],k,deriv)
     res.shape = oldshape + sh
     return res
                     



More information about the Scipy-svn mailing list