[Numpy-discussion] accumulation operation
Ralf Juengling
Ralf.Juengling at synopsys.com
Wed Jan 22 12:23:35 EST 2014
Executing the following code,
>>> import numpy as np
>>> a = np.zeros((3,))
>>> w = np.array([0, 1, 0, 1, 2])
>>> v = np.array([10.0, 1, 10.0, 2, 9])
>>> a[w] += v
I was expecting 'a' to be array([20., 3., 9.]. Instead I get
>>> a
array([ 10., 2., 9.])
This with numpy version 1.6.1.
Is there another way to do the accumulation I want?
Thanks,
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140122/7a6c901b/attachment.html>
More information about the NumPy-Discussion
mailing list