Skip to content

Unit overhaul 6/6: ExpressionComponent physical constants and parameter units#227

Open
henrikjacobsenfys wants to merge 1 commit into
split/02d-fit-bindingfrom
split/02e-expression-constants
Open

Unit overhaul 6/6: ExpressionComponent physical constants and parameter units#227
henrikjacobsenfys wants to merge 1 commit into
split/02d-fit-bindingfrom
split/02e-expression-constants

Conversation

@henrikjacobsenfys

@henrikjacobsenfys henrikjacobsenfys commented Jul 6, 2026

Copy link
Copy Markdown
Member

Add physical constants and per-parameter units to ExpressionComponent: hbar (meV·s) and kb (meV/K) are provided automatically as read-only constants when their symbol appears in an expression; parameter_units sets a unit per parameter without rescaling; the expression's output unit is derived from the parameter units and x_unit and a warning is issued when it disagrees with y_unit; parameters are dimensionless by default.

Split out of the unit-system overhaul as an independent feature stacked on the core rename (#224) and the FitBinding redesign (#226).

Also advances components.ipynb to demonstrate the ExpressionComponent parameter_units API; the tutorial notebooks run green under tutorial-tests on this branch.

All unit tests pass.


Stack — splitting the monolithic "Unit system overhaul" (#217) into a reviewable series. Merge bottom-up:

  1. Add unit-conversion utilities and FitTarget → develop (Unit overhaul 1/6: Add unit-conversion utilities and FitTarget #221)
  2. Centralize Q-index validation via verify_Q_indexsplit/01-unit-utils (Unit overhaul 2/6: Centralize Q-index validation via verify_Q_index #222)
  3. Store Q as a scipp Variable in 1/angstrom → split/02a-verify-q-index (Unit overhaul 3/6: Store Q as a scipp Variable in 1/angstrom #223)
  4. Separate model unit into x_unit/y_unit + tutorialssplit/02b-q-variable (Unit overhaul 4/6: Separate unit into x_unit/y_unit and update tutorials #224)
  5. Redesign FitBinding around FitTargetssplit/02c-unit-rename (Unit overhaul 5/6: Redesign FitBinding around FitTargets #226)
  6. ExpressionComponent physical constants + parameter unitssplit/02d-fit-binding (Unit overhaul 6/6: ExpressionComponent physical constants and parameter units #227)

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.61111% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.48%. Comparing base (508ba38) to head (4919c02).

Files with missing lines Patch % Lines
...cs/sample_model/components/expression_component.py 98.61% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                    @@
##           split/02d-fit-binding     #227      +/-   ##
=========================================================
+ Coverage                  98.28%   98.48%   +0.20%     
=========================================================
  Files                         53       53              
  Lines                       3897     4037     +140     
  Branches                     660      697      +37     
=========================================================
+ Hits                        3830     3976     +146     
+ Misses                        39       33       -6     
  Partials                      28       28              
Flag Coverage Δ
unittests 98.48% <98.61%> (+0.20%) ⬆️

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

Files with missing lines Coverage Δ
...cs/sample_model/components/expression_component.py 99.15% <98.61%> (+1.23%) ⬆️

... and 1 file with indirect coverage changes

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

@henrikjacobsenfys henrikjacobsenfys added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] medium Normal/default priority labels Jul 6, 2026
@henrikjacobsenfys henrikjacobsenfys force-pushed the split/02e-expression-constants branch from 54d558e to 49f8659 Compare July 6, 2026 19:45
Provide `hbar`/`kb` as read-only physical constants when they appear in
an expression, allow per-parameter units via `parameter_units`, derive
the expression's output unit and warn when it disagrees with y_unit, and
make parameters dimensionless by default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@henrikjacobsenfys henrikjacobsenfys force-pushed the split/02e-expression-constants branch from 49f8659 to 4919c02 Compare July 6, 2026 20:52
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] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant