Repository navigation
Preserve bond order and type in Structure addition and multiplication - #1438
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1414.
structure1 + structure2andstructure * ndroppedBond.orderandqualitative_typefor bonds coming from the right-hand operand, resetting them to order 1.0.__getitem__already passes["order", "qualitative_type"]asextra_attrsinto itscopy_valence_terms, but the__iadd__and__imul__copies of that helper lack the parameter.Both helpers now take
extra_attrsand the bond calls pass["order", "qualitative_type"]. A new test covers+and*, asserting the carried-over bonds keeporderandQualitativeBondType.pytest test/test_parmed_structure.pypasses locally on Python 3.9.