Suppose you have the following code
a = np.ones(8)
pos = np.array([1, 3, 5, 3])
a[pos] # returns array([ 1., 1., 1., 1.]), where the 2nd and 4th el are the same
a[pos] +=1
The last instruction returns
array([ 1., 2., 1., 2., 1., 2., 1., 1.])
But I'd like that assignments over same indices to be summed up, so as to obtain
array([ 1., 2., 1., 3., 1., 2., 1., 1.])
Someone has already experienced this same situation?