I've been puzzled with unexpected Python behavior: when I make a copy of my original numpy array and replace some of its elements with a different value, the corresponding elements of my original array gets updated, too. Here's a simple test:
>>import numpy as np
>>x = np.array([0,0,2,2])
>>x_adj = x
>>x_adj[x_adj <= 0] = 1
>>print x
>>print x_adj
[1 1 2 2]
[1 1 2 2]
I wonder, why the original array gets updated, too, and how to keep it intact so changes will be made to the copy only. Any feedback is welcome!