Skip to content

Skip dependent Parameters in fix_all_parameters and free_all_parameters - #301

Merged
henrikjacobsenfys merged 2 commits into
developfrom
fix-all-parameters-dependent
Nov 13, 2026
Merged

henrikjacobsenfys merged 2 commits into
developfrom
fix-all-parameters-dependent

Conversation

@henrikjacobsenfys

@henrikjacobsenfys henrikjacobsenfys commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Problem

fix_all_parameters() and free_all_parameters() raised on any model that has a dependent Parameter at some Q:

model = edyn.SampleModel(diffusion_models=edyn.BrownianTranslationalDiffusion(), Q=[0.5, 1.0])
model.fix_all_parameters()
# AttributeError: This is a dependent parameter, dependent parameters cannot be fixed.

Both methods set fixed on everything from get_all_variables(). That includes dependent Parameters, which cannot be fixed. They come from:

  • a diffusion model, whose per-Q width and area are generated from its own parameters,
  • a StretchedExponential, whose width depends on its other parameters (also in a ResolutionModel),
  • parameters the user tied to each other with make_dependent_on.

Change

Both methods now loop over get_fittable_parameters(), which is the independent Parameters only. Dependent Parameters are skipped; they follow the Parameters they depend on, and those are fixed or freed. ComponentCollection and ModelComponent already work this way.

Relation to other PRs

Tests

One regression test in test_model_base.py, next to the other fix_all_parameters tests: a per-Q parameter tied to another one with make_dependent_on. It fails on develop.

🤖 Generated with Claude Code

@henrikjacobsenfys henrikjacobsenfys added [scope] bug Bug report or fix (major.minor.PATCH) [priority] medium Normal/default priority labels Nov 12, 2026
@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.21%. Comparing base (4661fda) to head (55a1143).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #301   +/-   ##
========================================
  Coverage    98.21%   98.21%           
========================================
  Files           65       65           
  Lines         6399     6399           
  Branches      1082     1082           
========================================
  Hits          6285     6285           
  Misses          60       60           
  Partials        54       54           
Flag Coverage Δ
unittests 98.21% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/easydynamics/sample_model/model_base.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

henrikjacobsenfys and others added 2 commits November 12, 2026 23:09
Fixing or freeing all Parameters of a model raised an AttributeError
when a diffusion model was attached, because the per-Q Parameters a
diffusion model generates are dependent and cannot be fixed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The regression test was in test_sample_model.py and needed a diffusion
model. The method under test is ModelBase.fix_all_parameters, and a
parameter linked to another one with make_dependent_on reaches the bug
on a plain ModelBase, so the test moves to test_model_base.py.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@henrikjacobsenfys
henrikjacobsenfys force-pushed the fix-all-parameters-dependent branch from 9cf520e to 55a1143 Compare November 12, 2026 22:11
@henrikjacobsenfys
henrikjacobsenfys merged commit 5f40824 into develop Nov 13, 2026
45 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] medium Normal/default priority [scope] bug Bug report or fix (major.minor.PATCH)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant