I have an issue with numpy.copy not working as intended.
When using it as following, it still references the change back in my original list, which I want to avoid:
test = np.copy(random.sample(population_list, 2))
test[0][0][0][0] = 1.1111
If I print out population list
after the test assignment, it does replace the value in that position of population_list
with 1.1111. My goal is to sample from the list, and then make some changes to those samples, without affecting the initial list.
As further info, my population_list
is a list of lists, where the first element is a numpy matrix:
print(type(population_list))
print(type(population_list[0]))
print(type(population_list[0][0]))
print(type(population_list[0][0][0][0]))
list
list
numpy.ndarray
numpy.float64
Aucun commentaire:
Enregistrer un commentaire