Unit overhaul 3/6: Store Q as a scipp Variable in 1/angstrom#223
Open
henrikjacobsenfys wants to merge 1 commit into
Open
Unit overhaul 3/6: Store Q as a scipp Variable in 1/angstrom#223henrikjacobsenfys wants to merge 1 commit into
henrikjacobsenfys wants to merge 1 commit into
Conversation
Change _validate_and_convert_Q to return a scipp Variable (dimension 'Q', unit 1/angstrom) instead of a bare numpy array, and update the model hierarchy accordingly: ModelBase, InstrumentModel and DiffusionModelBase now expose Q as a Variable, compare Q with sc.allclose, and iterate via range(len(Q)); DeltaLorentz and the translational-diffusion models take .values where they need raw floats for naming and math. This carries the canonical Q unit through the public .Q property, so scipp Q values in any convertible unit (e.g. 1/nm) are accepted and normalized. Tests updated to read Q via .values. Split out of the larger unit-system branch. All unit tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## split/02a-verify-q-index #223 +/- ##
=========================================================
Coverage 97.47% 97.47%
=========================================================
Files 53 53
Lines 3685 3687 +2
Branches 640 640
=========================================================
+ Hits 3592 3594 +2
Misses 62 62
Partials 31 31
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Jul 6, 2026
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.
Change
_validate_and_convert_Qto return a scippVariable(dimension'Q', unit 1/angstrom) instead of a bare numpy array, and update the model hierarchy accordingly:ModelBase,InstrumentModelandDiffusionModelBasenow expose Q as aVariable, compare Q withsc.allclose, and iterate viarange(len(Q));DeltaLorentzand the translational-diffusion models take.valueswhere they need raw floats for naming and math.This carries the canonical Q unit through the public
.Qproperty, so scipp Q values in any convertible unit (e.g. 1/nm) are accepted and normalized. Tests updated to read Q via.values.All unit tests pass.
Stack — splitting the monolithic "Unit system overhaul" (#217) into a reviewable series. Merge bottom-up:
develop(Unit overhaul 1/6: Add unit-conversion utilities and FitTarget #221)verify_Q_index→split/01-unit-utils(Unit overhaul 2/6: Centralize Q-index validation via verify_Q_index #222)Variablein 1/angstrom →split/02a-verify-q-index(Unit overhaul 3/6: Store Q as a scipp Variable in 1/angstrom #223) (this PR)unitintox_unit/y_unit+ update tutorials →split/02b-q-variable(Unit overhaul 4/6: Separate unit into x_unit/y_unit and update tutorials #224)🤖 Generated with Claude Code