@@ -526,8 +526,8 @@ def reindex_atomnrs(self) -> dict[str, str]:
526
526
527
527
new_pairs = {}
528
528
new_multiple_dihedrals = {}
529
- new_dihedrals = {}
530
529
for dihedrals in self .proper_dihedrals .values ():
530
+ new_dihedrals = {}
531
531
ai = update_map .get (dihedrals .ai )
532
532
aj = update_map .get (dihedrals .aj )
533
533
ak = update_map .get (dihedrals .ak )
@@ -537,9 +537,10 @@ def reindex_atomnrs(self) -> dict[str, str]:
537
537
continue
538
538
539
539
# 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 ):
541
541
pair_ai = update_map .get (pair .ai )
542
542
pair_aj = update_map .get (pair .aj )
543
+
543
544
if None not in (pair_ai , pair_aj ):
544
545
pair .ai = pair_ai # type: ignore (pyright bug)
545
546
pair .aj = pair_aj # type: ignore
@@ -556,6 +557,7 @@ def reindex_atomnrs(self) -> dict[str, str]:
556
557
dihedral .ak = ak # type: ignore
557
558
dihedral .al = al # type: ignore
558
559
new_dihedrals [dihedral .periodicity ] = dihedral
560
+ dihedrals .dihedrals = new_dihedrals
559
561
560
562
new_multiple_dihedrals [
561
563
(
0 commit comments