[SciPy-user] Prob with romberg integration?

A. M. Archibald peridot.faceted at gmail.com
Fri Oct 13 15:13:01 CDT 2006

On 12/10/06, Neal Becker <ndbecker2 at gmail.com> wrote:
> A. M. Archibald wrote:
> > On 12/10/06, Neal Becker <ndbecker2 at gmail.com> wrote:
> >
> >> AttributeError: 'float' object has no attribute 'dtype'
> >
> > Looks like things are not getting converted to Numeric data types. A
> > bug, but easy to work around; just wrap the arguments in array()
> > calls.
> >
> If I print out the value of 'x' in quadrature.py/vectororize1 (the arg to
> vfunc), it seems that the first 2 times 'x' is a simple scalar, but the 3rd
> time it is a list with 1 element, and that triggers the error.
> Something's wrong here.

The bug appears to be in the function vectorize1 (which is internal to
scipy.integrate); it assumes that your function returns a numpy object
(which yours does not). Switching to "from numpy import exp, ..."
would probably cure the problem, as would wrapping the return value in

You might find that scipy.integrate.quad, which is based on solid
FORTRAN routines from QUADPACK, is faster and more reliable.

Nevertheless, that bug in scipy is annoying.

A. M. Archibald

More information about the SciPy-user mailing list