Deprecate rhat() and neff_ratio() in favor of extract_rhat()/extract_neff_ratio()#544
Open
utkarshpawade wants to merge 3 commits intostan-dev:masterfrom
Open
Deprecate rhat() and neff_ratio() in favor of extract_rhat()/extract_neff_ratio()#544utkarshpawade wants to merge 3 commits intostan-dev:masterfrom
utkarshpawade wants to merge 3 commits intostan-dev:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR resolves #295 by renaming bayesplot’s R-hat and ESS extractor APIs to avoid masking similarly named computational functions in the posterior package, while keeping the old names available via deprecation warnings.
Changes:
- Added new S3 generics
extract_rhat()/extract_neff_ratio()and renamed existing methods toextract_*.<class>. - Converted
rhat()/neff_ratio()into deprecated wrappers that warn vialifecycle::deprecate_warn()and forward to the new generics. - Updated docs, vignette examples, NAMESPACE, and tests to use the new names and to verify deprecation warnings.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
R/bayesplot-extractors.R |
Introduces extract_* generics/methods and makes rhat()/neff_ratio() deprecated forwarding wrappers. |
R/mcmc-diagnostics.R |
Updates roxygen references to point users to the new extractor names. |
R/mcmc-intervals.R |
Updates roxygen references/examples to use extract_rhat(). |
tests/testthat/test-extractors.R |
Renames extractor tests and adds coverage for deprecated wrapper behavior. |
vignettes/visual-mcmc-diagnostics.Rmd |
Updates vignette narrative and examples to use extract_* and explains the rename. |
man/bayesplot-extractors.Rd |
Adds aliases/usages for new generics and documents rhat()/neff_ratio() as deprecated. |
man/MCMC-diagnostics.Rd |
Updates documentation examples/links to use extract_neff_ratio()/extract_rhat(). |
man/MCMC-intervals.Rd |
Updates links/examples to use extract_rhat(). |
NAMESPACE |
Exports new generics and registers their S3 methods; removes old rhat/neff_ratio method registrations. |
NEWS.md |
Adds a NEWS entry describing the deprecation/rename rationale. |
💡 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 #544 +/- ##
=======================================
Coverage 99.18% 99.18%
=======================================
Files 35 35
Lines 6118 6142 +24
=======================================
+ Hits 6068 6092 +24
Misses 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Fixes #295
Deprecates
rhat()andneff_ratio()in favor ofextract_rhat()andextract_neff_ratio(). The old names clashed with same-named functions in the posterior package, which actually compute R-hat / ESS, whereas bayesplot's versions only extract already-computed values from a fitted model. The name collision maskedposterior::rhat()when both packages were loaded and confused users about what the functions were doing under the hood.Per the discussion in #295, rename + deprecate was the only viable path, posterior's functions aren't drop-in replacements, so wrapping or removal wasn't an option.
changes:
extract_rhat()/extract_neff_ratio()with the existingstanfit,stanreg, andCmdStanMCMCmethods renamed to match.rhat()andneff_ratio()are now thin deprecated wrappers that emitlifecycle::deprecate_warn("1.16.0", ...)and forward to the new generics. Behavior is otherwise unchanged, so existing user code keeps working with a warning.NAMESPACEandman/*.Rdregenerated via roxygen.rhat/neff_ratioS3 classes (used bymcmc_rhat_data(),[.rhat,diagnostic_factor.rhat, etc.) are intentionally left alone, they describe data objects, not the deprecated functions.