<div>Hello, </div><div><br></div><div>I've noticed that If you try to increment elements of an array with advanced indexing, repeated indexes don't get repeatedly incremented. For example:</div><div><br></div><div>
<div>In [30]: x = zeros(5)</div><div><br></div><div>In [31]: idx = array([1,1,1,3,4])</div><div><br></div><div>In [32]: x[idx] += [2,4,8,10,30]</div><div><br></div><div>In [33]: x</div><div>Out[33]: array([  0.,   8.,   0.,  10.,  30.])</div>
</div><div><br></div><div>I would intuitively expect the output to be array([0,14, 0,10,30]) since index 1 is incremented by 2+4+8=14, but instead it seems to only increment by 8. What is numpy actually doing here? </div>
<div><br></div><div>The authors of Theano noticed this behavior a while ago so they python loop through the values in idx (this kind of calculation is necessary for calculating gradients), but this is a bit slow for my purposes, so I'd like to figure out how to get the behavior I expected, but faster. </div>
<div><br></div><div>I'm also not sure how to navigate the numpy codebase, where would I look for the code responsible for this behavior?</div>