Can you run this and tell why a is not equal to x_copy?
#Define x,y and swap_inds x = np.array([1, 2, 3, 4]) y = np.array([4, 3, 2, 1]) swap_inds = np.random.random(size=len(x)) < 0.5 #Print out swap_inds print(swap_inds) #Method 1 x_copy = np.copy(x) y_copy = np.copy(y) x_copy[swap_inds] = y[swap_inds] print(x_copy) #Method 2 a = x_copy[swap_inds] b = y[swap_inds] a=b print(a)