Unit overhaul 2/6: Centralize Q-index validation via verify_Q_index#222
Open
henrikjacobsenfys wants to merge 1 commit into
Open
Unit overhaul 2/6: Centralize Q-index validation via verify_Q_index#222henrikjacobsenfys wants to merge 1 commit into
henrikjacobsenfys wants to merge 1 commit into
Conversation
Replace the AnalysisBase._verify_Q_index method and the various inline Q_index type/bounds checks scattered across the model hierarchy with the shared verify_Q_index helper (added in the previous PR). Callers now delegate validation to a single function with consistent error messages and behavior (TypeError for non-int, IndexError for negative/out-of-range, upper-bound deferred when Q is None). Migrated: Analysis, Analysis1d, AnalysisBase, Experiment, ModelBase, InstrumentModel, DiffusionModelBase and DeltaLorentz. Tests updated to the unified messages. 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/01-unit-utils #222 +/- ##
=======================================================
+ Coverage 97.32% 97.47% +0.14%
=======================================================
Files 53 53
Lines 3707 3685 -22
Branches 660 640 -20
=======================================================
- Hits 3608 3592 -16
+ Misses 65 62 -3
+ Partials 34 31 -3
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.
Replace the
AnalysisBase._verify_Q_indexmethod and the various inlineQ_indextype/bounds checks scattered across the model hierarchy with the sharedverify_Q_indexhelper (added in the previous PR). Callers now delegate validation to a single function with consistent error messages and behavior (TypeErrorfor non-int,IndexErrorfor negative/out-of-range, upper-bound deferred when Q is None).Migrated:
Analysis,Analysis1d,AnalysisBase,Experiment,ModelBase,InstrumentModel,DiffusionModelBaseandDeltaLorentz. Tests updated to the unified messages.Net: 15 files, +71/−236 (removes duplicated validation blocks). 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) (this PR)Variablein 1/angstrom →split/02a-verify-q-index(Unit overhaul 3/6: Store Q as a scipp Variable in 1/angstrom #223)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