Repository navigation
feat: add component.py - #5
Merged
Merged
Conversation
Contributor
Author
|
@sbillinge ready for merge. I closed the other PR because it was stalling #4 |
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.
Implements the two helpers on
Componentthat every component (peak profile, instrument, texture) uses for its refinable values:create_parameters_from(refinable_obj, names)creates the component's srfit Parameters from a pyobjcryst model. Each Parameter starts at ObjCryst's default value, with ObjCryst's limits as its bounds.namesmaps our Parameter names to ObjCryst's ({"eta0": "Eta0"}), so the names users see don't depend on ObjCryst's. Some of those can't be Python names (2ThetaDispl), and some will change when workarounds are replaced.push_parameters(refinable_obj)writes the Parameter values into a pyobjcryst model before each calculation.Why the limits matter: ObjCryst silently clamps a value set outside its limits. If a fit steps to W = 2 while the limit is 1, srfit reports W = 2 but the pattern is calculated with W = 1, and the fit stops responding to W. To prevent this:
least_squares(..., bounds=recipe.get_bounds_array())stays inside them.push_parametersraises aValueErrorif a value gets past a limit anyway, naming the limit and the value ObjCryst would have used. All values are checked before any is written, so an error leaves the model unchanged.