I have this dictionary,
dict = {'A':np.random.rand(2,2), 'B':np.random.rand(2,2)}
For some reasons, I need to to get a copy of items inside this dictionary and manipulate them as follows,
for key, value in dict.items():
tmp = value
tmp[1, 1] = 0
This actually changes the original values inside the dict! If I get a print, for example of the first entry, I will see:
Initial value
[[0.46905019 0.5143053 ]
[0.9083885 0.62560836]]
Final Value
[[0.46905019 0.5143053 ]
[0.9083885 0. ]]
So, how I can have a copy of dictionary items and manipulate them without changing the original values? Of course, one trivial solution is to make a copy of dictionary and work with the copy, but is there any other solution? And more importantly, is this behavior intentional or it is kind of unwanted?