Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-29 Thread Bruce Southey
On 03/29/2010 10:17 AM, Ryan May wrote: > On Mon, Mar 29, 2010 at 8:00 AM, Bruce Southey wrote: > >> On 03/27/2010 01:31 PM, Ryan May wrote: >> >>> Because of the call to asarray(), the mask is completely discarded and >>> you end up with identical results to an unmasked array, >>> which

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-29 Thread Ryan May
Hi, I decided that having actual code that does what I want and keeps backwards compatibility (and adds tests) might be better than arguing semantics. I've updated my patch to: * Uses the array.sum() method instead of add.reduce to make subclasses fully work (this was still breaking masked array

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-29 Thread Ryan May
On Mon, Mar 29, 2010 at 8:00 AM, Bruce Southey wrote: > On 03/27/2010 01:31 PM, Ryan May wrote: >> Because of the call to asarray(), the mask is completely discarded and >> you end up with identical results to an unmasked array, >> which is not what I'd expect.  Worse, the actual numeric value of

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-29 Thread Bruce Southey
On 03/27/2010 01:31 PM, Ryan May wrote: > On Sat, Mar 27, 2010 at 11:12 AM, wrote: > >> On Sat, Mar 27, 2010 at 1:00 PM, Ryan May wrote: >> >>> On Mon, Mar 22, 2010 at 8:14 AM, Ryan May wrote: >>> On Sun, Mar 21, 2010 at 11:57 PM, wrote: > On Mon, Mar 2

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-28 Thread Darren Dale
On Sat, Mar 27, 2010 at 10:23 PM, wrote: > subclasses of ndarray, like masked_arrays and quantities, and classes > that delegate to array calculations, like pandas, can redefine > anything. So there is not much that can be relied on if any subclass > is allowed to be used inside a function > > e.

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-27 Thread josef . pktd
On Sat, Mar 27, 2010 at 11:37 PM, Ryan May wrote: > On Sat, Mar 27, 2010 at 8:23 PM,   wrote: >> Matrices have been part of numpy for a long time and your patch would >> break backwards compatibility in a pretty serious way. > > Yeah, and I should admit that I realize that makes this particular >

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-27 Thread Ryan May
On Sat, Mar 27, 2010 at 8:23 PM, wrote: > Matrices have been part of numpy for a long time and your patch would > break backwards compatibility in a pretty serious way. Yeah, and I should admit that I realize that makes this particular patch a no-go. However, that to me doesn't put the issue to

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-27 Thread josef . pktd
On Sat, Mar 27, 2010 at 2:31 PM, Ryan May wrote: > On Sat, Mar 27, 2010 at 11:12 AM,   wrote: >> On Sat, Mar 27, 2010 at 1:00 PM, Ryan May wrote: >>> On Mon, Mar 22, 2010 at 8:14 AM, Ryan May wrote: On Sun, Mar 21, 2010 at 11:57 PM,   wrote: > On Mon, Mar 22, 2010 at 12:49 AM, Ryan May

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-27 Thread Ryan May
On Sat, Mar 27, 2010 at 11:12 AM, wrote: > On Sat, Mar 27, 2010 at 1:00 PM, Ryan May wrote: >> On Mon, Mar 22, 2010 at 8:14 AM, Ryan May wrote: >>> On Sun, Mar 21, 2010 at 11:57 PM,   wrote: On Mon, Mar 22, 2010 at 12:49 AM, Ryan May wrote: > Hi, > > I found that trapz() doesn

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-27 Thread josef . pktd
On Sat, Mar 27, 2010 at 1:00 PM, Ryan May wrote: > On Mon, Mar 22, 2010 at 8:14 AM, Ryan May wrote: >> On Sun, Mar 21, 2010 at 11:57 PM,   wrote: >>> On Mon, Mar 22, 2010 at 12:49 AM, Ryan May wrote: Hi, I found that trapz() doesn't work with subclasses: http://projects.

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-27 Thread Ryan May
On Mon, Mar 22, 2010 at 8:14 AM, Ryan May wrote: > On Sun, Mar 21, 2010 at 11:57 PM,   wrote: >> On Mon, Mar 22, 2010 at 12:49 AM, Ryan May wrote: >>> Hi, >>> >>> I found that trapz() doesn't work with subclasses: >>> >>> http://projects.scipy.org/numpy/ticket/1438 >>> >>> A simple patch (attache

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-22 Thread Ryan May
On Sun, Mar 21, 2010 at 11:57 PM, wrote: > On Mon, Mar 22, 2010 at 12:49 AM, Ryan May wrote: >> Hi, >> >> I found that trapz() doesn't work with subclasses: >> >> http://projects.scipy.org/numpy/ticket/1438 >> >> A simple patch (attached) to change asarray() to asanyarray() fixes >> the problem

Re: [Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-21 Thread josef . pktd
On Mon, Mar 22, 2010 at 12:49 AM, Ryan May wrote: > Hi, > > I found that trapz() doesn't work with subclasses: > > http://projects.scipy.org/numpy/ticket/1438 > > A simple patch (attached) to change asarray() to asanyarray() fixes > the problem fine. Are you sure this function works with matrices

[Numpy-discussion] numpy.trapz() doesn't respect subclass

2010-03-21 Thread Ryan May
Hi, I found that trapz() doesn't work with subclasses: http://projects.scipy.org/numpy/ticket/1438 A simple patch (attached) to change asarray() to asanyarray() fixes the problem fine. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma fix_trapz_subcla