[Numpy-discussion] Different behaviour of python built sum and addition on ndarrays
Christopher Mutel
cmutel@gmail....
Mon Apr 16 17:06:11 CDT 2012
So, for both 1.5 and 1.6 (at least), it appears that the builtin sum
does not add ndarrays the way "+" (and operator.add) do:
a = np.arange(10).reshape((2,5))
b = np.arange(10, 20).reshape((2,5))
sum(a,b)
Out[5]:
array([[15, 18, 21, 24, 27],
[20, 23, 26, 29, 32]])
a + b
Out[6]:
array([[10, 12, 14, 16, 18],
[20, 22, 24, 26, 28]])
Is this expected? I couldn't find a description of why this would
occur in the mailing list or in the documentation. I can't figure out
what sum does at all, actually, as it doesn't seem to be a case of
strange broadcasting or any other tricks I tried.
Yours, Chris
--
############################
Chris Mutel
Ökologisches Systemdesign - Ecological Systems Design
Institut f.Umweltingenieurwissenschaften - Institute for Environmental
Engineering
ETH Zürich - HIF C 44 - Schafmattstr. 6
8093 Zürich
Telefon: +41 44 633 71 45 - Fax: +41 44 633 10 61
############################
More information about the NumPy-Discussion
mailing list