[Scipy-svn] r4181 - trunk/scipy/interpolate

scipy-svn at scipy.org scipy-svn at scipy.org
Sun Apr 27 01:13:10 EDT 2008


Author: peridot
Date: 2008-04-27 00:13:08 -0500 (Sun, 27 Apr 2008)
New Revision: 4181

Modified:
   trunk/scipy/interpolate/polyint.py
Log:
Improved exception raising for misshapen derivatives, and a fix for return-value shape. PiecewisePolynomial still doesn't distinguish between scalar and one-dimensional vector results, though.


Modified: trunk/scipy/interpolate/polyint.py
===================================================================
--- trunk/scipy/interpolate/polyint.py	2008-04-26 23:33:30 UTC (rev 4180)
+++ trunk/scipy/interpolate/polyint.py	2008-04-27 05:13:08 UTC (rev 4181)
@@ -468,10 +468,7 @@
         assert n2<=len(y2)
 
         xi = np.zeros(n)
-        if self.r==1:
-            yi = np.zeros(n)
-        else:
-            yi = np.zeros((n,self.r))
+        yi = np.zeros((n,self.r))
         xi[:n1] = x1
         yi[:n1] = y1[:n1]
         xi[n1:] = x2
@@ -498,6 +495,13 @@
         self.xi.append(xi)
         self.yi.append(yi)
 
+        for y in yi:
+            if np.shape(y) != (self.r,):
+                if self.r>1:
+                    raise ValueError, "Each derivative must be a vector of length %d" % self.r
+                else:
+                    raise ValueError, "Each derivative must be a scalar"
+
         if order is None:
             n1 = len(self.yi[-2])
             n2 = len(self.yi[-1])




More information about the Scipy-svn mailing list