ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> scipy-user
scipy-user
[SciPy-user] strange error in integrate.romb
by Gael Varoquaux other posts by this author
Dec 13 2006 1:43PM messages near this date
Re: [SciPy-user] csc, csr sparse complex matrix problems. | Re: [SciPy-user] strange error in integrate.romb
Hi, 

I don't really understand how integrate.romb is supposed to work.

First of all its docstring is not really clear:

""" Uses Romberg integration to integrate y(x) using N samples along the
given axis which are assumed equally spaced with distance dx. The
number of samples must be 1 + a non-negative power of two: N=2**k + 1 
"""

Reading this it is not clear that y is supposed to be a vector, and not a
function.

Second if I run it on a really simple test case, I get an error, and it
seems the error is due to a trivial bug in the code:

In [13]: x = arange(0,2**10+1)

In [14]: integrate.romb(x)
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most
recent call last)

/home/varoquau/<ipython console>  

/usr/lib/python2.4/site-packages/scipy/integrate/quadrature.py in romb(y,
dx, axis, show)
    256     for i in range(2,k+1):
    257         start > >= 1
-->  258         slice_R = tupleset(slice_R, slice(start,stop,step))
    259         step > >= 1
    260         R[(i,1)] = 0.5*(R[(i-1,1)] +
h*add.reduce(y[slice_R],axis))

TypeError: tupleset() takes exactly 3 arguments (2 given)

In [15]:

And indeed if you check out the code for tupleset, you find this :

def tupleset(t, i, value):
    l = list(t)
    l[i] = value
    return tuple(l)

It looks to me there has been some refactoring and the integrate.romb has
been left out.

Cheers,

Gaël
_______________________________________________
SciPy-user mailing list
SciPy-user@[...].org
http://projects.scipy.org/mailman/listinfo/scipy-user
Thread:
Gael Varoquaux
Travis Oliphant
Gael Varoquaux

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved