Repository navigation
fix: fix .show() crash when restraints weren't added add_soft_bounds() - #227
Merged
Merged
Conversation
Contributor
Author
|
@sbillinge ready for review, The description is very claude-y 😂 but i felt it did a good job describing the changes |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #227 +/- ##
===========================================
+ Coverage 71.63% 84.70% +13.07%
===========================================
Files 25 43 +18
Lines 3437 4805 +1368
===========================================
+ Hits 2462 4070 +1608
+ Misses 975 735 -240
🚀 New features to boost your workflow:
|
Contributor
Author
|
I think codecov isnt happy because |
Contributor
|
yes, claudy but easy to follow. It will be work to test those string methods and if we change them the test will break for no particularly good reason, so I think this is ok as it is. |
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.
What problem does this PR address?
Closes #24
show()crashed with anAttributeErrorwhenever a recipe held a restraint that wasn't made byadd_soft_bounds. That includes:restrainBVS()Restraintadded directly withregister_soft_bounds()Why:
show()printed every restraint aseqstr: lower_bound = ..., upper_bound = ..., sig = ..., scaled = .... Only restraints made byadd_soft_boundshave those attributes. The others store different information. For example, an ObjCryst restraint only wraps a pyobjcryst object, soshow()failed when it tried to read them.Fix: Each restraint class now describes itself through
__str__, andshow()prints what each restraint returns:show()add_soft_bounds("p", 0, 2)(unchanged)p: lower_bound = 0.000000, upper_bound = 2.000000, sig = 1.000000, scaled = FalseRestraintviaregister_soft_boundseq_p: lower_bound = 0.000000, upper_bound = 2.000000, sig = 1.000000, scaled = FalseBVS of nacl: sig = 0.500000, scaled = TrueC0-C5: length = 3.300000, sigma = 0.100000, delta = 0.200000, scaled = FalseC0-C5-C7: angle = 1.000000, sigma = 0.100000, delta = 0.200000, scaled = FalseBefore:
After: the Restraints section lists
BVS of nacl: sig = 1.000000, scaled = False.Changes:
Restraintsetseqstrto the equation's name by default, so a restraint built by hand has something to show.add_soft_boundsstill overrides it as before.Restraint,BVSRestraintandObjCrystMoleculeRestrainteach get a__str__. The ObjCryst one also covers restraints wrapped from an existing molecule withwrapRestraints().Tests: I added
show()tests for each kind of restraint intest_recipeorganizer.py,test_diffpyparset.pyandtest_objcrystparset.py.What should the reviewer(s) do?
Please review and merge. One point you may want to check:
ObjCrystMoleculeRestraint.__str__decides between a bond length and an angle by checkinghasattr(res, "GetLength0"). It has to work this way because restraints wrapped from an existing molecule (wrapRestraints()) are plainObjCrystMoleculeRestraintobjects, not the bond-length or angle subclasses.