Skip to content

Commit 2481423

Browse files
committed
fix: update dihedrals, make pairs unique
1 parent 7358177 commit 2481423

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/kimmdy/topology/topology.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ def reindex_atomnrs(self) -> dict[str, str]:
526526

527527
new_pairs = {}
528528
new_multiple_dihedrals = {}
529-
new_dihedrals = {}
530529
for dihedrals in self.proper_dihedrals.values():
530+
new_dihedrals = {}
531531
ai = update_map.get(dihedrals.ai)
532532
aj = update_map.get(dihedrals.aj)
533533
ak = update_map.get(dihedrals.ak)
@@ -537,9 +537,10 @@ def reindex_atomnrs(self) -> dict[str, str]:
537537
continue
538538

539539
# do pairs before the dihedrals are updated
540-
if pair := self.pairs.get((dihedrals.ai, dihedrals.al)):
540+
if pair := self.pairs.pop((dihedrals.ai, dihedrals.al), False):
541541
pair_ai = update_map.get(pair.ai)
542542
pair_aj = update_map.get(pair.aj)
543+
543544
if None not in (pair_ai, pair_aj):
544545
pair.ai = pair_ai # type: ignore (pyright bug)
545546
pair.aj = pair_aj # type: ignore
@@ -556,6 +557,7 @@ def reindex_atomnrs(self) -> dict[str, str]:
556557
dihedral.ak = ak # type: ignore
557558
dihedral.al = al # type: ignore
558559
new_dihedrals[dihedral.periodicity] = dihedral
560+
dihedrals.dihedrals = new_dihedrals
559561

560562
new_multiple_dihedrals[
561563
(

0 commit comments

Comments
 (0)