I am trying to apply a simple boolean mask to a np array. Following is an easy example.
temp = np.arange(5)
print(temp)
temp1 = temp
temp1[temp1 < 2] = 0
print(temp1)
print(temp)
I have already assign the value of temp to a new variable temp1, so what I expected is that the mask only applies on the variable temp1. However, the value of temp is also updated. I wonder why is this happening.
Result:
[0 1 2 3 4]
[0 0 2 3 4]
[0 0 2 3 4]