Make diagnostic color matching explicit for neff#470
Conversation
There was a problem hiding this comment.
Pull request overview
Removes reliance on R’s partial argument matching for diagnostic name resolution in color/fill scale helpers, making "neff" vs "neff_ratio" handling explicit (Fixes #469).
Changes:
- Expanded diagnostic name matching to explicitly include
"neff"and"neff_ratio", normalizing"neff"to"neff_ratio"internally. - Added test coverage to ensure
"neff"/"neff_ratio"inputs don’t error. - Documented the behavior change in NEWS.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/testthat/test-mcmc-diagnostics.R | Adds regression test for explicit handling of "neff" vs "neff_ratio" |
| R/mcmc-diagnostics.R | Makes accepted diagnostic names explicit and normalizes "neff" to "neff_ratio" |
| NEWS.md | Notes the explicit handling and removal of reliance on partial matching |
Comments suppressed due to low confidence (1)
R/mcmc-diagnostics.R:432
- The PR description says the helpers accept
rhat,neff, andneff_ratio, butscale_fill_diagnostic()(and likelyscale_color_diagnostic()as well) still only declarec("rhat", "neff"), which will reject"neff_ratio"(it won’t partial-match a longer string to"neff"). Consider updating these wrapper defaults/choices to include"neff_ratio"(and rely ondiagnostic_color_scale()to normalize"neff"→"neff_ratio"), so the documented API matches actual behavior.
scale_fill_diagnostic <- function(diagnostic = c("rhat", "neff")) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #470 +/- ##
=======================================
Coverage 98.66% 98.66%
=======================================
Files 35 35
Lines 5860 5860
=======================================
Hits 5782 5782
Misses 78 78 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
The issue is real but this solution seems way too complicated. I think we can avoid all these changes by just switching the diagnostic argument to scale_color_diagnostic from diagnostic = c("rhat", "neff") to diagnostic = c("rhat", "neff_ratio") and then replacing:
scale_color_diagnostic("neff") -> scale_color_diagnostic("neff_ratio")
wherever that's used. Same for scale_fill_diagnostic. Does that make sense?
These are internal functions so we don't need to worry about breaking backwards compatibility, so we shouldn't accept both neff and neff_ratio if we don't need to.
|
Yes, that makes sense and it aligns with a minimal change approach; I’ll inspect the current branch state (including any recent edits) and then simplify the implementation exactly as requested. |
Fixes #469
This PR removes reliance on partial matching when resolving diagnostic names for color/fill scales.
Previously the wrapper accepted
neffwhile internal helpers expectedneff_ratio, which worked only because of partial matching. This change makes the accepted names explicit.Changes
rhat,neff, andneff_rationefftoneff_ratiointernally