coarse-graining / cgnet

learning coarse-grained force fields
BSD 3-Clause "New" or "Revised" License
57 stars 26 forks source link

small stats fix (no functionality change) #137

Closed brookehus closed 4 years ago

brookehus commented 4 years ago

Development:

I was debugging some scripts I have and ran into issues (1) understanding my own logic in feature/statistics and (2) having something weird happen with some hidden attributes. I've added a deepcopy to solve this, which replaces former line 164:

self.bond_pairs = self._adj_backbone_pairs

with new line 176:

self.bond_pairs = copy.deepcopy(self._adj_backbone_pairs).

Besides that and import copy, the only other changes are some more documentation.

nec4 commented 4 years ago

Will review tonight!

brookehus commented 4 years ago

Yeah. If instead of a deep copy I use the previous

self.bond_pairs = self._adj_backbone_pairs

then this is a reference, not a new list. Then, when I extend self.bond_pairs later, in the old version self._adj_backbone_pairs also gets extended. I was trying to debug something and wanted to check if all the adjacent backbone pairs were correctly calculated, but the hidden attribute was getting my custom pairs too because of the lack of deep copy.

nec4 commented 4 years ago

Gotcha - nice catch! LGTM