[Numpy-discussion] A correction to numpy trapz function

Charles R Harris charlesr.harris at gmail.com
Sun Jul 13 01:49:06 EDT 2008


On Sat, Jul 12, 2008 at 10:30 PM, Nadav Horesh <nadavh at visionsense.com>
wrote:

> I am aware that the error is related to the broadcasting, and that it can
> be solved by matching the shape of x to that of y --- this is how I solved
> it in the first place. I was thinking that the function "promises" to
> integrate over an array given a x vector and the axis, so let obscure the
> broadcasting rules and just enable it to do the work. There is a reason to
> leave trapz as it is (or even drop it) since numpy should stay as close as
> possible to "bare metal", but this function is borrowed also by scipy
> integration package, thus I rather give it a face lift.
>

I think you can pretty much borrow the average function to do this, all you
need to do is generate the proper weights and scaling. It's in
numpy/lib/function_base.py

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080712/8c085502/attachment.html>


More information about the NumPy-Discussion mailing list