Repository navigation
Add make_parameter_Q_independent to ModelBase - #298
Merged
Merged
Conversation
Address one Parameter of a named component at every Q, or at a single Q, without looping over the per-Q component collections by hand. Fixing or freeing at every Q also updates the template, so it survives a rebuild. Part of #70. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Tie one Parameter of a named component to a single value across Q, by making it at every other Q dependent on the one at Q index 0. The model stores the tie and reapplies it whenever the per-Q collections are rebuilt or patched. remove_parameter_Q_constraint undoes it. Part of #70. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #298 +/- ##
===========================================
+ Coverage 98.26% 98.27% +0.01%
===========================================
Files 65 65
Lines 6504 6548 +44
Branches 1094 1105 +11
===========================================
+ Hits 6391 6435 +44
Misses 60 60
Partials 53 53
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…eter # Conflicts: # tests/unit/easydynamics/sample_model/test_sample_model.py
This was referenced Nov 12, 2026
The description promises that fixing a dependent parameter raises the EasyScience AttributeError; that is now tested. Two tests matched the full text of an EasyScience KeyError and only need the missing name. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Found by an independent review, each reproduced with a script. - A constraint on a component generated by a diffusion model outlived remove_diffusion_model, and remove_parameter_Q_constraint then raised a KeyError. SampleModel recorded the diffusion models' versions after the base class reapplied the constraints, which it skips while the collections count as stale. The two lines are swapped. - clear_components without Q kept the constraint for a later component of the same name, since pruning only runs on per-Q collections. clear_components now clears the constraints. Also: say in the docstring which fixed flags a removed constraint leaves, and drop a test that repeated get_parameters' own. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…eter # Conflicts: # tests/unit/easydynamics/sample_model/test_model_base.py # tests/unit/easydynamics/sample_model/test_sample_model.py
…ue-70-q-independent # Conflicts: # tests/unit/easydynamics/sample_model/test_model_base.py
copy and to_dict/from_dict re-create a model from its __init__ arguments, so constraints added with make_parameter_Q_independent were lost. to_dict now writes them under 'Q_independent_parameters', and from_dict reapplies them after construction. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dent # Conflicts: # src/easydynamics/sample_model/model_base.py # tests/unit/easydynamics/sample_model/test_model_base.py # tests/unit/easydynamics/sample_model/test_sample_model.py
henrikjacobsenfys
changed the base branch from
issue-70-fix-parameter
to
develop
November 24, 2026 10:23
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.
Part of #70 (second of four PRs). Stacked on #297; review that one first.
Problem
To make a parameter take one value at all Q, users had to call EasyScience's
make_dependent_onon each per-Q parameter by hand. Those hand-made dependencies were also lost whenever the per-Q collections were rebuilt.Change
fit_method='simultaneous'; in an independent fit the value comes from the fit of Q index 0 alone.fix_parameter/free_parameter: on a Q-independent parameter they act on Q index 0 and the template, and the other Q follow.ValueError, e.g. a parameter generated by a diffusion model.remove_parameter_Q_constraintmakes every Q independent again, each keeping its current value.Tests
New
# Q constraints (issue #70)section intest_model_base.py.Review
Merge #301 first. With a Q constraint on a plain model,
fix_all_parameters()andfree_all_parameters()raiseAttributeError: ... dependent parameters cannot be fixeduntil #301 is in.An independent review reproduced two bugs, both fixed and covered:
remove_diffusion_model, andremove_parameter_Q_constraintthen raised aKeyError.clear_components()with Q unset kept the constraint for a later component of the same name.Things to be aware of:
remove_parameter_Q_constraintleaves mixed fixed flags. Q index 0 keeps its flag and the other Q come back free, since a dependent parameter has none.normalize_area()raises on a tied area, as it does for the areas a diffusion model generates.JointAnalysis(Add JointAnalysis for fitting several data sets together #290), a tie works when it is set on the model of the first analysis. On a following model the link overwrites it.🤖 Generated with Claude Code