[Numpy-discussion] reduction

lorenzo bolla lbolla at gmail.com
Mon Jan 8 10:23:59 EST 2007

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?

Can someone explain me this?
Thank you in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070108/62a26602/attachment.html>

More information about the NumPy-Discussion mailing list