Skip to content

Preserve bond order and type in Structure addition and multiplication - #1438

Merged
swails merged 1 commit into
ParmEd:masterfrom
barlowa124:iadd-bond-orders-1414
Oct 9, 2026
Merged

swails merged 1 commit into
ParmEd:masterfrom
barlowa124:iadd-bond-orders-1414

Conversation

@barlowa124

Copy link
Copy Markdown
Contributor

Fixes #1414.

structure1 + structure2 and structure * n dropped Bond.order and qualitative_type for bonds coming from the right-hand operand, resetting them to order 1.0. __getitem__ already passes ["order", "qualitative_type"] as extra_attrs into its copy_valence_terms, but the __iadd__ and __imul__ copies of that helper lack the parameter.

Both helpers now take extra_attrs and the bond calls pass ["order", "qualitative_type"]. A new test covers + and *, asserting the carried-over bonds keep order and QualitativeBondType. pytest test/test_parmed_structure.py passes locally on Python 3.9.

Structure.__iadd__ and __imul__ dropped Bond.order and
qualitative_type when copying valence terms, so bonds contributed by
the right-hand structure reverted to order 1.0 with no type. Pass
those attributes through copy_valence_terms the same way
__getitem__ already does.

Fixes ParmEd#1414

@swails swails left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@swails
swails merged commit d808d72 into ParmEd:master Oct 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bond orders lost after structure addition

2 participants