I was trying to vectorize some list calculation, but find something weird when I attempting to use list as index, especially when I try to write back to the original list, repeated list index seems to be useless:
import numpy as np
x = np.arange(10)
y = np.array([1,2,3,4,5])
z = np.array([1,1,1,1,1])
print(x[y], x[z])
>>out: [1 2 3 4 5] [1 1 1 1 1], same as I expected
x = np.arange(10)
x[y] -= 1
print(x[y])
>>out: [0 1 2 3 4] this is good as no repeating in index list
x = np.arange(10)
x[z] -= 1
print(x[y])
>> out:[0 2 3 4 5], Here I am expecting [-4 2 3 4 5], which means x[1] should -- for 5 times, but it turns out to subtract only once