[Numpy-discussion] reduction

lorenzo bolla lbolla at gmail.com
Mon Jan 8 10:38:42 CST 2007


Well, I don't know if we should consider it a bug, but it definetely behaves
not as expected by the standard "reduce", right?
I'm very happy to help: just tell me how to "file a ticket"! (what does it
mean, by the way?).
thanks!
lorenzo.


On 1/8/07, Charles R Harris <charlesr.harris at gmail.com> wrote:
>
>
>
>  On 1/8/07, Charles R Harris <charlesr.harris at gmail.com> wrote:
> >
> >
> >
> > On 1/8/07, lorenzo bolla < lbolla at gmail.com> wrote:
> > >
> > > Hello all!
> > > I'm fairly new to Numpy and, while experimenting, I found a strange (
> > > i.e. not expected by me!) behaviour of arrays.
> > > I tried this (in comment what I get):
> > >
> > > x = arange(4)      # x = array([0,1,2,3])
> > >
> > > def myadd(x,y):    # re-define the binary sum function
> > >     return x + y
> > >
> > > reduce(myadd, x)     # 6, as expected
> > >  add.reduce(x)     # 6, as expected
> > >
> > > def mysub(x,y):   # re-define the binary diff function
> > >     return x - y
> > >
> > > reduce(mysub, x)    # -6, as expected
> > > subtract.reduce(x)    # 2 ---> WHY?
> > >
> >
> > It might be a bug in the implementation. What is happening is that
> > instead of subtracting the new number from the previous result, the previous
> > result is being subtracted from the new number. So you start with 0, and the
> > sequence of operations continues:
> >
> > 0 = 0 - 0
> > 1 = 1 - 0
> > 1 = 2 - 1
> > 2 = 3 - 1
> > 2 = 4 - 2
> > 3 = 5 - 2
> >
> > Definitely a bug. Want to file a ticket?
> >
>
> Or maybe not a bug. It depends on what reduce means for this operation. So
> either a bug or something that could use a bit of documentation.
>
> Chuck
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070108/2834730d/attachment.html 


More information about the Numpy-discussion mailing list