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

scipy-svn at scipy.org scipy-svn at scipy.org
Thu Sep 23 11:27:55 EDT 2010


Author: rgommers
Date: 2010-09-23 10:27:54 -0500 (Thu, 23 Sep 2010)
New Revision: 6821

Modified:
   trunk/scipy/integrate/ode.py
   trunk/scipy/integrate/quadpack.py
   trunk/scipy/integrate/quadrature.py
Log:
DOC: make docs in integrate module conform to documentation standard.

Modified: trunk/scipy/integrate/ode.py
===================================================================
--- trunk/scipy/integrate/ode.py	2010-09-23 09:18:06 UTC (rev 6820)
+++ trunk/scipy/integrate/ode.py	2010-09-23 15:27:54 UTC (rev 6821)
@@ -1,6 +1,6 @@
 # Authors: Pearu Peterson, Pauli Virtanen, John Travers
 """
-First-order ODE integrators
+First-order ODE integrators.
 
 User-friendly interface to various numerical integrators for solving a
 system of first order ODEs with prescribed initial conditions::
@@ -35,7 +35,7 @@
 This class has the same generic interface as ode, except it can handle complex
 f, y and Jacobians by transparently translating them into the equivalent
 real valued system. It supports the real valued solvers (i.e not zvode) and is
-an alternative to ode with the zvode solver, sometimes performing better. 
+an alternative to ode with the zvode solver, sometimes performing better.
 """
 
 integrator_info = \
@@ -109,21 +109,21 @@
 
     Numerical solution of a system of first order
     ordinary differential equations  y'=f(x,y).
-    this is an explicit runge-kutta method of order (4)5  
+    this is an explicit runge-kutta method of order (4)5
     due to Dormand & Prince (with stepsize control and
     dense output).
 
     Authors: E. Hairer and G. Wanner
              Universite de Geneve, Dept. de Mathematiques
-             CH-1211 Geneve 24, Switzerland 
+             CH-1211 Geneve 24, Switzerland
              e-mail:  ernst.hairer at math.unige.ch
                       gerhard.wanner at math.unige.ch
-     
-    This code is described in: 
+
+    This code is described in:
           E. Hairer, S.P. Norsett and G. Wanner, Solving Ordinary
           Differential Equations i. Nonstiff Problems. 2nd edition.
           Springer Series in Computational Mathematics,
-          Springer-Verlag (1993)               
+          Springer-Verlag (1993)
 
 This integrator accepts the following parameters in set_integrator()
 method of the ode class:
@@ -150,7 +150,7 @@
 
     Numerical solution of a system of first 0rder
     ordinary differential equations  y'=f(x,y).
-    this is an explicit runge-kutta method of order 8(5,3)  
+    this is an explicit runge-kutta method of order 8(5,3)
     due to Dormand & Prince (with stepsize control and
     dense output).
 
@@ -295,7 +295,7 @@
         Parameters
         ----------
         name : str
-            Name of the integrator
+            Name of the integrator.
         integrator_params :
             Additional parameters for the integrator.
         """
@@ -345,8 +345,12 @@
         return self
 
 class complex_ode(ode):
-    """ A wrapper of ode for complex systems. """
+    """ A wrapper of ode for complex systems.
 
+    For usage examples, see `ode`.
+
+    """
+
     def __init__(self, f, jac=None):
         """
         Define equation y' = f(y,t), where y and f can be complex.
@@ -366,13 +370,13 @@
             ode.__init__(self, self._wrap, self._wrap_jac)
         else:
             ode.__init__(self, self._wrap, None)
-            
+
     def _wrap(self, t, y, *f_args):
         f = self.cf(*((t, y[::2] + 1j*y[1::2]) + f_args))
         self.tmp[::2] = real(f)
         self.tmp[1::2] = imag(f)
         return self.tmp
-        
+
     def _wrap_jac(self, t, y, *jac_args):
         jac = self.cjac(*((t, y[::2] + 1j*y[1::2]) + jac_args))
         self.jac_tmp[1::2,1::2] = self.jac_tmp[::2,::2] = real(jac)
@@ -681,7 +685,7 @@
     def run(self,*args):
         y1,t,istate = self.runner(*(args[:5]+tuple(self.call_args)+args[5:]))
         if istate < 0:
-            warnings.warn('zvode: ' + 
+            warnings.warn('zvode: ' +
                 self.messages.get(istate, 'Unexpected istate=%s'%istate))
             self.success = 0
         else:
@@ -744,11 +748,11 @@
     def run(self,f,jac,y0,t0,t1,f_params,jac_params):
         x,y,iwork,idid = self.runner(*((f,t0,y0,t1) + tuple(self.call_args)))
         if idid < 0:
-            warnings.warn(self.name + ': ' + 
+            warnings.warn(self.name + ': ' +
                 self.messages.get(idid, 'Unexpected idid=%s'%idid))
             self.success = 0
         return y,x
-        
+
     def _solout(self, *args):
         # dummy solout function
         pass

Modified: trunk/scipy/integrate/quadpack.py
===================================================================
--- trunk/scipy/integrate/quadpack.py	2010-09-23 09:18:06 UTC (rev 6820)
+++ trunk/scipy/integrate/quadpack.py	2010-09-23 15:27:54 UTC (rev 6821)
@@ -114,17 +114,17 @@
   information dictionary contains the following entries instead of 'last',
   'alist', 'blist', 'rlist', and 'elist':
 
-  'lst' -- The number of subintervals needed for the integration (call it K_f).
-  'rslst' -- A rank-1 array of length M_f=limlst, whose first K_f elements
+  'lst'    : The number of subintervals needed for the integration (call it K_f).
+  'rslst'  : A rank-1 array of length M_f=limlst, whose first K_f elements
              contain the integral contribution over the interval (a+(k-1)c,
              a+kc) where c = (2*floor(|w|) + 1) * pi / |w| and k=1,2,...,K_f.
-  'erlst' -- A rank-1 array of length M_f containing the error estimate
+  'erlst'  : A rank-1 array of length M_f containing the error estimate
              corresponding to the interval in the same position in
              infodict['rslist'].
-  'ierlst' -- A rank-1 integer array of length M_f containing an error flag
-              corresponding to the interval in the same position in
-              infodict['rslist'].  See the explanation dictionary (last entry
-              in the output tuple) for the meaning of the codes.
+  'ierlst' : A rank-1 integer array of length M_f containing an error flag
+             corresponding to the interval in the same position in
+             infodict['rslist'].  See the explanation dictionary (last entry
+             in the output tuple) for the meaning of the codes.
 """)
     return
 
@@ -207,16 +207,15 @@
 
     See Also
     --------
-        dblquad, tplquad - double and triple integrals
-        fixed_quad - fixed-order Gaussian quadrature
-        quadrature - adaptive Gaussian quadrature
-        odeint, ode - ODE integrators
-        simps, trapz, romb - integrators for sampled data
-        scipy.special - for coefficients and roots of orthogonal polynomials
+    dblquad, tplquad : double and triple integrals
+    fixed_quad : fixed-order Gaussian quadrature
+    quadrature : adaptive Gaussian quadrature
+    odeint, ode : ODE integrators
+    simps, trapz, romb : integrators for sampled data
+    scipy.special : for coefficients and roots of orthogonal polynomials
 
     Examples
     --------
-
     Calculate :math:`\\int^4_0 x^2 dx` and compare with an analytic result
 
     >>> from scipy import integrate
@@ -232,7 +231,6 @@
     >>> integrate.quad(invexp,0,inf)
     (0.99999999999999989, 5.8426061711142159e-11)
 
-
     >>> f = lambda x,a : a*x
     >>> y, err = integrate.quad(f, 0, 1, args=(1,))
     >>> y
@@ -375,46 +373,48 @@
 
 def dblquad(func, a, b, gfun, hfun, args=(), epsabs=1.49e-8, epsrel=1.49e-8):
     """
-    Compute the double integral of func2d(y,x)
-    from x=a..b and y=gfun(x)..hfun(x).
+    Compute a double integral.
 
+    Return the double (definite) integral of func(y,x) from x=a..b and
+    y=gfun(x)..hfun(x).
+
     Parameters
     -----------
-      func2d : function
-             a Python function or method of at least two variables: y must be
-             the first argument and x the second argument.
-      (a,b)  : tuple
-             the limits of integration in x: a < b
-      gfun   : function
-             the lower boundary curve in y which is a function taking a single
-             floating point argument (x) and returning a floating point result:
-             a lambda function can be useful here.
-      hfun   : function
-             the upper boundary curve in y (same requirements as gfun).
-      args   :
-             extra arguments to pass to func2d.
-      epsabs : float
-             absolute tolerance passed directly to the inner 1-D quadrature
-             integration.
-      epsrel : float
-             relative tolerance of the inner 1-D integrals.
+    func : callable
+        A Python function or method of at least two variables: y must be the
+        first argument and x the second argument.
+    (a,b) : tuple
+        The limits of integration in x: a < b
+    gfun : callable
+        The lower boundary curve in y which is a function taking a single
+        floating point argument (x) and returning a floating point result: a
+        lambda function can be useful here.
+    hfun : callable
+        The upper boundary curve in y (same requirements as `gfun`).
+    args : sequence, optional
+        Extra arguments to pass to `func2d`.
+    epsabs : float, optional
+        Absolute tolerance passed directly to the inner 1-D quadrature
+        integration. Default is 1.49e-8.
+    epsrel : float
+        Relative tolerance of the inner 1-D integrals. Default is 1.49e-8.
 
-
     Returns
-    -----------
-      y      : float
-             the resultant integral.
-      abserr : float
-             an estimate of the error.
+    -------
+    y : float
+        The resultant integral.
+    abserr : float
+        An estimate of the error.
 
-    See also:
-        quad - single integral
-        tplquad - triple integral
-        fixed_quad - fixed-order Gaussian quadrature
-        quadrature - adaptive Gaussian quadrature
-        odeint, ode - ODE integrators
-        simps, trapz, romb - integrators for sampled data
-        scipy.special - for coefficients and roots of orthogonal polynomials
+    See also
+    --------
+    quad : single integral
+    tplquad : triple integral
+    fixed_quad : fixed-order Gaussian quadrature
+    quadrature : adaptive Gaussian quadrature
+    odeint, ode : ODE integrators
+    simps, trapz, romb : integrators for sampled data
+    scipy.special : for coefficients and roots of orthogonal polynomials
 
     """
     return quad(_infunc,a,b,(func,gfun,hfun,args),epsabs=epsabs,epsrel=epsrel)
@@ -430,12 +430,12 @@
     """
     Compute a triple (definite) integral.
 
-    Return the triple integral of func3d(z, y,x) from
+    Return the triple integral of func(z, y, x) from
     x=a..b, y=gfun(x)..hfun(x), and z=qfun(x,y)..rfun(x,y)
 
     Parameters
     ----------
-    func3d : function
+    func : function
         A Python function or method of at least three variables in the
         order (z, y, x).
     (a,b) : tuple
@@ -453,11 +453,11 @@
         The upper boundary surface in z. (Same requirements as qfun.)
     args : Arguments
         Extra arguments to pass to func3d.
-    epsabs : float
+    epsabs : float, optional
         Absolute tolerance passed directly to the innermost 1-D quadrature
-        integration.
-    epsrel : float
-        Relative tolerance of the innermost 1-D integrals.
+        integration. Default is 1.49e-8.
+    epsrel : float, optional
+        Relative tolerance of the innermost 1-D integrals. Default is 1.49e-8.
 
     Returns
     -------

Modified: trunk/scipy/integrate/quadrature.py
===================================================================
--- trunk/scipy/integrate/quadrature.py	2010-09-23 09:18:06 UTC (rev 6820)
+++ trunk/scipy/integrate/quadrature.py	2010-09-23 15:27:54 UTC (rev 6821)
@@ -176,7 +176,7 @@
 def cumtrapz(y, x=None, dx=1.0, axis=-1):
     """
     Cumulatively integrate y(x) using samples along the given axis
-    and the composite trapezoidal rule.  If x is None, spacing given by dx
+    and the composite trapezoidal rule.  If x is None, spacing given by `dx`
     is assumed.
 
     Parameters
@@ -196,19 +196,18 @@
 
     See Also
     --------
+    quad: adaptive quadrature using QUADPACK
+    romberg: adaptive Romberg quadrature
+    quadrature: adaptive Gaussian quadrature
+    fixed_quad: fixed-order Gaussian quadrature
+    dblquad: double integrals
+    tplquad: triple integrals
+    romb: integrators for sampled data
+    trapz: integrators for sampled data
+    cumtrapz: cumulative integration for sampled data
+    ode: ODE integrators
+    odeint: ODE integrators
 
-      quad: adaptive quadrature using QUADPACK
-      romberg: adaptive Romberg quadrature
-      quadrature: adaptive Gaussian quadrature
-      fixed_quad: fixed-order Gaussian quadrature
-      dblquad: double integrals
-      tplquad: triple integrals
-      romb: integrators for sampled data
-      trapz: integrators for sampled data
-      cumtrapz: cumulative integration for sampled data
-      ode: ODE integrators
-      odeint: ODE integrators
-
     """
     y = asarray(y)
     if x is None:
@@ -359,41 +358,37 @@
 
 def romb(y, dx=1.0, axis=-1, show=False):
     """
-    Romberg integration using samples of a function
+    Romberg integration using samples of a function.
 
     Parameters
     -----------
-      y : array like
-           a vector of 2**k + 1 equally-spaced samples of a function
-
-      dx : array like
-           the sample spacing.
-
-      axis : array like?
-           the axis along which to integrate
-
-      show : Boolean
-           When y is a single 1-d array, then if this argument is True
+    y : array_like
+        A vector of ``2**k + 1`` equally-spaced samples of a function.
+    dx : array_like, optional
+        The sample spacing. Default is 1.
+    axis : array_like?, optional
+        The axis along which to integrate. Default is -1 (last axis).
+    show : bool, optional
+           When y is a single 1-D array, then if this argument is True
            print the table showing Richardson extrapolation from the
-           samples.
+           samples. Default is False.
 
     Returns
-    -----------
+    -------
+    ret : array_like?
+        The integrated result for each axis.
 
-       ret : array_like?
-          The integrated result for each axis.
+    See also
+    --------
+    quad - adaptive quadrature using QUADPACK
+    romberg - adaptive Romberg quadrature
+    quadrature - adaptive Gaussian quadrature
+    fixed_quad - fixed-order Gaussian quadrature
+    dblquad, tplquad - double and triple integrals
+    simps, trapz - integrators for sampled data
+    cumtrapz - cumulative integration for sampled data
+    ode, odeint - ODE integrators
 
-    See also:
-
-      quad - adaptive quadrature using QUADPACK
-      romberg - adaptive Romberg quadrature
-      quadrature - adaptive Gaussian quadrature
-      fixed_quad - fixed-order Gaussian quadrature
-      dblquad, tplquad - double and triple integrals
-      simps, trapz - integrators for sampled data
-      cumtrapz - cumulative integration for sampled data
-      ode, odeint - ODE integrators
-
     """
     y = asarray(y)
     nd = len(y.shape)
@@ -570,7 +565,7 @@
 
     Examples
     --------
-    Integrate a gaussian from 0,1 and compare to the error function.
+    Integrate a gaussian from 0 to 1 and compare to the error function.
 
     >>> from scipy.special import erf
     >>> gaussian = lambda x: 1/np.sqrt(np.pi) * np.exp(-x**2)
@@ -686,7 +681,7 @@
         1275983280000)
     }
 
-def newton_cotes(rn,equal=0):
+def newton_cotes(rn, equal=0):
     """
     Return weights and error coefficient for Newton-Cotes integration.
 
@@ -705,22 +700,20 @@
 
     Parameters
     ----------
-
     rn : int
-        The integer order for equally-spaced data
-        or the relative positions of the samples with
-        the first sample at 0 and the last at N, where
-        N+1 is the length of rn.  N is the order of the Newton
+        The integer order for equally-spaced data or the relative positions of
+        the samples with the first sample at 0 and the last at N, where N+1 is
+        the length of `rn`.  N is the order of the Newton-Cotes integration.
     equal: int, optional
-        Set to 1 to enforce equally spaced data
+        Set to 1 to enforce equally spaced data.
 
     Returns
     -------
-    an : array
-        1-d array of weights to apply to the function at
-        the provided sample positions.
-    B  : float
-        error coefficient
+    an : ndarray
+        1-D array of weights to apply to the function at the provided sample
+        positions.
+    B : float
+        Error coefficient.
 
     Notes
     -----




More information about the Scipy-svn mailing list