[Scipy-svn] r6908 - trunk/scipy/integrate

scipy-svn@scip... scipy-svn@scip...
Fri Nov 19 22:36:40 CST 2010


Author: warren.weckesser
Date: 2010-11-19 22:36:39 -0600 (Fri, 19 Nov 2010)
New Revision: 6908

Modified:
   trunk/scipy/integrate/ode.py
   trunk/scipy/integrate/quadpack.py
   trunk/scipy/integrate/quadrature.py
Log:
ENH: integrate: update 'raise' statements.

Modified: trunk/scipy/integrate/ode.py
===================================================================
--- trunk/scipy/integrate/ode.py	2010-11-18 11:40:52 UTC (rev 6907)
+++ trunk/scipy/integrate/ode.py	2010-11-20 04:36:39 UTC (rev 6908)
@@ -444,18 +444,18 @@
         Return 2-tuple (y1,t1) where y1 is the result and t=t1
         defines the stoppage coordinate of the result.
         """
-        raise NotImplementedError,\
-        'all integrators must define run(f,jac,t0,t1,y0,f_params,jac_params)'
+        raise NotImplementedError('all integrators must define '
+                'run(f,jac,t0,t1,y0,f_params,jac_params)')
 
     def step(self,f,jac,y0,t0,t1,f_params,jac_params):
         """Make one integration step and return (y1,t1)."""
-        raise NotImplementedError,'%s does not support step() method' %\
-              (self.__class__.__name__)
+        raise NotImplementedError('%s does not support step() method' %
+                self.__class__.__name__)
 
     def run_relax(self,f,jac,y0,t0,t1,f_params,jac_params):
         """Integrate from t=t0 to t>=t1 and return (y1,t)."""
-        raise NotImplementedError,'%s does not support run_relax() method' %\
-              (self.__class__.__name__)
+        raise NotImplementedError('%s does not support run_relax() method' %
+                self.__class__.__name__)
 
     #XXX: __str__ method for getting visual state of the integrator
 

Modified: trunk/scipy/integrate/quadpack.py
===================================================================
--- trunk/scipy/integrate/quadpack.py	2010-11-18 11:40:52 UTC (rev 6907)
+++ trunk/scipy/integrate/quadpack.py	2010-11-20 04:36:39 UTC (rev 6908)
@@ -285,7 +285,7 @@
             print "Warning: " + msg
             return retval[:-1]
     else:
-        raise ValueError, msg
+        raise ValueError(msg)
 
 
 def _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points):
@@ -302,7 +302,7 @@
         infbounds = -1
         bound = b
     else:
-        raise RuntimeError, "Infinity comparisons don't work for you."
+        raise RuntimeError("Infinity comparisons don't work for you.")
 
     if points is None:
         if infbounds == 0:
@@ -311,7 +311,7 @@
             return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
     else:
         if infbounds !=0:
-            raise ValueError, "Infinity inputs cannot be used with break points."
+            raise ValueError("Infinity inputs cannot be used with break points.")
         else:
             nl = len(points)
             the_points = numpy.zeros((nl+2,), float)
@@ -322,7 +322,7 @@
 def _quad_weight(func,a,b,args,full_output,epsabs,epsrel,limlst,limit,maxp1,weight,wvar,wopts):
 
     if weight not in ['cos','sin','alg','alg-loga','alg-logb','alg-log','cauchy']:
-        raise ValueError, "%s not a recognized weighting function." % weight
+        raise ValueError("%s not a recognized weighting function." % weight)
 
     strdict = {'cos':1,'sin':2,'alg':1,'alg-loga':2,'alg-logb':3,'alg-log':4}
 
@@ -354,10 +354,10 @@
             args = (func,) + args
             return _quadpack._qawfe(thefunc,-b,wvar,integr,args,full_output,epsabs,limlst,limit,maxp1)
         else:
-            raise ValueError, "Cannot integrate with this weight from -Inf to +Inf."
+            raise ValueError("Cannot integrate with this weight from -Inf to +Inf.")
     else:
         if a in [-Inf,Inf] or b in [-Inf,Inf]:
-            raise ValueError, "Cannot integrate with this weight over an infinite interval."
+            raise ValueError("Cannot integrate with this weight over an infinite interval.")
 
         if weight[:3] == 'alg':
             integr = strdict[weight]

Modified: trunk/scipy/integrate/quadrature.py
===================================================================
--- trunk/scipy/integrate/quadrature.py	2010-11-18 11:40:52 UTC (rev 6907)
+++ trunk/scipy/integrate/quadrature.py	2010-11-20 04:36:39 UTC (rev 6908)
@@ -52,8 +52,8 @@
     x = real(x)
     ainf, binf = map(isinf,(a,b))
     if ainf or binf:
-        raise ValueError, "Gaussian quadrature is only available for " \
-              "finite limits."
+        raise ValueError("Gaussian quadrature is only available for "
+                "finite limits.")
     y = (b-a)*(x+1)/2.0 + a
     return (b-a)/2.0*sum(w*func(y,*args),0), None
 
@@ -317,19 +317,18 @@
             returnshape = 1
             x=x.reshape(tuple(shapex))
         elif len(x.shape) != len(y.shape):
-            raise ValueError, "If given, shape of x must be 1-d or the " \
-                  "same as y."
+            raise ValueError("If given, shape of x must be 1-d or the "
+                    "same as y.")
         if x.shape[axis] != N:
-            raise ValueError, "If given, length of x along axis must be the " \
-                  "same as y."
+            raise ValueError("If given, length of x along axis must be the "
+                    "same as y.")
     if N % 2 == 0:
         val = 0.0
         result = 0.0
         slice1 = (slice(None),)*nd
         slice2 = (slice(None),)*nd
         if not even in ['avg', 'last', 'first']:
-            raise ValueError, \
-                  "Parameter 'even' must be 'avg', 'last', or 'first'."
+            raise ValueError("Parameter 'even' must be 'avg', 'last', or 'first'.")
         # Compute using Simpson's rule on first intervals
         if even in ['avg', 'first']:
             slice1 = tupleset(slice1, axis, -1)
@@ -400,8 +399,8 @@
         n <<= 1
         k += 1
     if n != Ninterv:
-        raise ValueError, \
-              "Number of samples must be one plus a non-negative power of 2."
+        raise ValueError("Number of samples must be one plus a "
+                "non-negative power of 2.")
 
     R = {}
     all = (slice(None),) * nd
@@ -737,8 +736,8 @@
         return na*np.array(vi,float)/da, float(nb)/db
 
     if (rn[0] != 0) or (rn[-1] != N):
-        raise ValueError, "The sample positions must start at 0"\
-              " and end at N"
+        raise ValueError("The sample positions must start at 0"
+                " and end at N")
     yi = rn / float(N)
     ti = 2.0*yi - 1
     nvec = np.arange(0,N+1)



More information about the Scipy-svn mailing list