I'm experiencing a problem with array indexing. Suppose you have an array a and another array b you want to use to use as index for a in order to assign some values to the position pointed by b elements.
a=numpy.zeros(5)
print a
[ 0. 0. 0. 0. 0.]
Now I would like to increase the second element twice
b=numpy.array([1,1])
a[b]+=1.
print a
[ 0. 1. 0. 0. 0.]
while I expected to have
[ 0. 2. 0. 0. 0.]
There are no problems if the array b has no redundancies (all values of its elements are different). Has somebody got a solution for such a problem which avoids using for loops? Is it a bug in numpy? Thanks in advance