BOT: Fix #454: Deduplicate interval coverage bounds-check logic#1097
Draft
nikosbosse wants to merge 1 commit intomainfrom
Draft
BOT: Fix #454: Deduplicate interval coverage bounds-check logic#1097nikosbosse wants to merge 1 commit intomainfrom
nikosbosse wants to merge 1 commit intomainfrom
Conversation
Extract shared bounds-check `(observed >= lower) & (observed <= upper)` into `check_interval_coverage()` helper, used by both `get_coverage()` and `interval_coverage()` to eliminate duplicated logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1097 +/- ##
=======================================
Coverage 97.83% 97.83%
=======================================
Files 35 35
Lines 1845 1846 +1
=======================================
+ Hits 1805 1806 +1
Misses 40 40 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nikosbosse
commented
Feb 13, 2026
Collaborator
Author
nikosbosse
left a comment
There was a problem hiding this comment.
CLAUDE: Approve — Clean, minimal refactoring that correctly extracts the duplicated bounds-check logic into a shared internal helper check_interval_coverage(). The change is purely mechanical with no behavioral impact. Both original implementations computed the same expression — the helper standardizes the operand order. Well-guarded by 6 new regression tests covering cross-validation between code paths, boundary cases, and full-dataset comparison against score() output. No issues found.
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.
Summary
(observed >= lower) & (observed <= upper)into a shared internal helpercheck_interval_coverage()get_coverage()(R/get-coverage.R) andinterval_coverage()(R/metrics-quantile.R) now call this helper instead of independently implementing the same logicFixes #454
Root cause
Both
get_coverage()andinterval_coverage()independently implemented the same interval bounds check after callingquantile_to_interval(). The logic was identical but the operand order differed (observed <= upper & observed >= lowervsobserved >= lower & observed <= upper).What the fix does
check_interval_coverage(observed, lower, upper)inR/helper-quantile-interval-range.Rget_coverage()andinterval_coverage()to call the shared helper(observed >= lower) & (observed <= upper)Test coverage added
get_coverage()interval coverage matchesinterval_coverage()for same dataget_coverage()vsscore()🤖 Generated with Claude Code