strange error in integrate.romb
![](https://secure.gravatar.com/avatar/5c9fb379c4e97b58960d74dcbfc5dee5.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/49df8cd4b1b6056c727778925f86147a.jpg?s=120&d=mm&r=g)
Gael Varoquaux wrote:
Hi,
I don't really understand how integrate.romb is supposed to work.
First of all its docstring is not really clear:
I've tried to clean it up.
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:
Hmm. Which version do you have? It seems to be right in my version of scipy. -Travis
![](https://secure.gravatar.com/avatar/5c9fb379c4e97b58960d74dcbfc5dee5.jpg?s=120&d=mm&r=g)
On Wed, Dec 13, 2006 at 03:02:20PM -0700, Travis Oliphant wrote:
I've tried to clean it up.
Great, thanks. I would have sent a patch if I had svn installed on this box. Good docstrings are really important.
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:
Hmm. Which version do you have? It seems to be right in my version of scipy.
Ooops, I forgot to specify this. I have 0.5.1, shipped by Ubuntu Edgy. I just checked svn on the net (I should have done this before). The docstring is much more helpful, and indeed the bug is gone. Sorry about the noise. Gaël
participants (2)
-
Gael Varoquaux
-
Travis Oliphant