I have a numpy array called initial_matrix and inside a for-loop in each step of the loop I want to randomly change one of the indexes of that array (every time a different one) and the process my matrix.
init_matrix = deepcopy(my_matrix)
for i in range(0, 30):
new_mat, rep_index = replace_index(my_matrix, value)
...// proceed with my process
The function replace_index, randomly reaplces one index of the matreix with the value. I noticed that the results of the replacement it does not occur only to new_mat but also to my_matrix. However, I want in each step of the loop to use my initial matrix and not the one after the replacement of the array. How can I do so?