Skip to content

Commit ff85ef1

Browse files
committed
Preserve S3 dispatch on deprecated rhat()/neff_ratio()
1 parent ce45938 commit ff85ef1

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ S3method(log_posterior,stanfit)
1717
S3method(log_posterior,stanreg)
1818
S3method(melt_mcmc,matrix)
1919
S3method(melt_mcmc,mcmc_array)
20+
S3method(neff_ratio,default)
2021
S3method(num_chains,data.frame)
2122
S3method(num_chains,mcmc_array)
2223
S3method(num_iters,data.frame)
@@ -36,6 +37,7 @@ S3method(pp_check,default)
3637
S3method(print,bayesplot_function_list)
3738
S3method(print,bayesplot_grid)
3839
S3method(print,bayesplot_scheme)
40+
S3method(rhat,default)
3941
export(abline_01)
4042
export(available_mcmc)
4143
export(available_ppc)

R/bayesplot-extractors.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ extract_neff_ratio <- function(object, ...) {
8181
}
8282

8383
# rhat -------------------------------------------------------------
84+
# Kept as an S3 generic (not just a wrapper) so third-party methods
85+
# registered against rhat (e.g. brms::rhat.brmsfit) still dispatch
86+
# during the deprecation window.
8487
#' @rdname bayesplot-extractors
8588
#' @export
8689
rhat <- function(object, ...) {
@@ -94,8 +97,16 @@ rhat <- function(object, ...) {
9497
"masking posterior::rhat(), which computes R-hat)."
9598
)
9699
)
100+
UseMethod("rhat")
101+
}
102+
103+
#' @rdname bayesplot-extractors
104+
#' @export
105+
#' @method rhat default
106+
rhat.default <- function(object, ...) {
97107
extract_rhat(object, ...)
98108
}
109+
99110
# neff_ratio -------------------------------------------------------------
100111
#' @rdname bayesplot-extractors
101112
#' @export
@@ -110,6 +121,13 @@ neff_ratio <- function(object, ...) {
110121
"size ratios (and to avoid masking posterior's ESS functions)."
111122
)
112123
)
124+
UseMethod("neff_ratio")
125+
}
126+
127+
#' @rdname bayesplot-extractors
128+
#' @export
129+
#' @method neff_ratio default
130+
neff_ratio.default <- function(object, ...) {
113131
extract_neff_ratio(object, ...)
114132
}
115133

man/bayesplot-extractors.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)