Repository navigation
Add get_parameters, fix_parameter and free_parameter to ModelBase - #297
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]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #297 +/- ##
========================================
Coverage 98.25% 98.26%
========================================
Files 65 65
Lines 6477 6504 +27
Branches 1088 1094 +6
========================================
+ Hits 6364 6391 +27
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:
|
This was referenced Nov 12, 2026
…eter # Conflicts: # tests/unit/easydynamics/sample_model/test_sample_model.py
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]>
…eter # Conflicts: # tests/unit/easydynamics/sample_model/test_model_base.py # tests/unit/easydynamics/sample_model/test_sample_model.py
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 (first of four PRs).
Problem
To fix one parameter at every Q, users had to loop over the per-Q component collections by hand, as tutorial 2 did:
Change
Three methods on
ModelBase, soSampleModel,ResolutionModelandBackgroundModelall get them. A parameter is addressed by component name and attribute name:fix_all_parameters. A single-Q change leaves the template alone.KeyError, an attribute that is not aParameterraisesValueError, and fixing a dependent parameter raises the existing EasyScienceAttributeError.Tutorial
The two fixing loops in
tutorial2_nanoparticles.ipynbare replaced byfix_parametercalls. The notebook still runs.Tests
New
# Single-parameter access (issue #70)sections intest_model_base.pyandtest_sample_model.py.Review
An independent review found no bugs in this PR. Changes from it: a test for the
AttributeErroron a dependent parameter, which the description promised, and two tests that no longer pin the text of an EasyScience message.Limits worth knowing:
fix_parameter('P', 'c0')raisesValueError: Component 'P' has no Parameter 'c0', since the coefficients are not attributes of the component. That matters forBackgroundModel, where a Polynomial is the usual component.SampleModelextends its Q grid.Q_indexwith Q unset raises a bareIndexError.🤖 Generated with Claude Code