I am trying to use advanced indexing to update arrays, but am unsure of how to do it. For example:
foo = np.array([0, 0, 0])
bar = np.array([0, 2, 1, 0])
barr = np.array([3, 6, 9, 12])
foo[bar] += barr
print(foo)
I expect:
>>> [15, 9, 6]
but instead I get
>>> [12, 9, 6]
which probably means += doesn't update the foo array. Is there another way of achieving this?