Skip to content

Rework diffusion models#191

Merged
henrikjacobsenfys merged 30 commits into
developfrom
delta-lorentz
May 29, 2026
Merged

Rework diffusion models#191
henrikjacobsenfys merged 30 commits into
developfrom
delta-lorentz

Conversation

@henrikjacobsenfys
Copy link
Copy Markdown
Member

@henrikjacobsenfys henrikjacobsenfys commented May 22, 2026

The changes are described here: #190

I'm missing some tests, but the code is more or less how I want it to be, so a review would be nice

@henrikjacobsenfys henrikjacobsenfys added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] medium Normal/default priority labels May 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 95.92326% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.13%. Comparing base (fff0285) to head (38ecbae).

Files with missing lines Patch % Lines
...mple_model/diffusion_model/diffusion_model_base.py 93.20% 5 Missing and 2 partials ⚠️
...mics/sample_model/diffusion_model/delta_lorentz.py 97.59% 3 Missing and 3 partials ⚠️
src/easydynamics/analysis/fit_binding.py 0.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #191      +/-   ##
===========================================
- Coverage    98.42%   98.13%   -0.29%     
===========================================
  Files           50       51       +1     
  Lines         3175     3542     +367     
  Branches       576      652      +76     
===========================================
+ Hits          3125     3476     +351     
- Misses          26       36      +10     
- Partials        24       30       +6     
Flag Coverage Δ
integration 44.91% <35.01%> (-1.26%) ⬇️
unittests 98.02% <94.96%> (-0.41%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henrikjacobsenfys henrikjacobsenfys marked this pull request as ready for review May 26, 2026 07:42
@henrikjacobsenfys henrikjacobsenfys added [priority] high Should be prioritized soon and removed [priority] medium Normal/default priority labels May 26, 2026
Comment thread src/easydynamics/sample_model/diffusion_model/delta_lorentz.py Outdated
Comment thread src/easydynamics/sample_model/sample_model.py
@rozyczko
Copy link
Copy Markdown
Member

rozyczko commented May 29, 2026

Thread 1 — Double-counting lorentzian_width in get_all_variables()

Good catch, and well fixed.

Thread 2 — Aggressive reset on Q change in SampleModel._on_Q_change()

I think your reasoning sounds good for now. The key points:

  1. Changing Q fundamentally invalidates Q-dependent parameters (per-Q A_0, per-Q lorentzian_width) — there's no reliable way to determine which subset remain valid after the change.
  2. The user is explicitly warned when changing Q (it requires confirm=True).
  3. The # This may be too aggressive comment serves as a good reminder that this could be revisited.

My suggestion would be to leave the current behaviour as-is for this PR (since it's documented that Q changes are destructive), but perhaps add a note in the docstring of SampleModel.Q setter or _on_Q_change() that clarifies this trade-off explicitly for users. Something along the lines of:

"Changing Q will reset all diffusion model parameters that depend on Q (per-Q amplitudes and widths). This is necessary because the validity of those parameters cannot be determined after a Q change. To avoid accidental data loss, Q changes require confirm=True."

Copy link
Copy Markdown
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@henrikjacobsenfys henrikjacobsenfys merged commit 556b95f into develop May 29, 2026
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] high Should be prioritized soon [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider if DiffusionModel should store Q internally Make sure diffusion models generate the correct dependent parameters

2 participants