Commit 55de310
committed
Be careful with shallow copies of dicts of dicts! (eg. bonds matrices)
When you do a shallow copy of a dictionary of dictionaries, the inner dictionaries
have not been copied - they are the original ones. This is important when you have:
bonds1[atom1][atom2] = bond
then
bonds2 = bonds.copy()
is NOT a safe copy to manipulate without messing up bonds1.
It is NOT a 2-D array, but a dictionary of mutable dictionaries.
You need to copy it at least one level deep (see the diff)1 parent 872d9c2 commit 55de310
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1139 | 1139 | | |
1140 | 1140 | | |
1141 | 1141 | | |
1142 | | - | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1143 | 1148 | | |
1144 | 1149 | | |
1145 | 1150 | | |
| |||
0 commit comments