Skip to content

Commit 22b745d

Browse files
Merge branch 'master' into fix-diagnostic-color-scale-match-arg
2 parents 47b573e + eb8046f commit 22b745d

63 files changed

Lines changed: 941 additions & 712 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
env:
3030
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3131
R_KEEP_PKG_SOURCE: yes
32+
R_VERSION_TYPE: ${{ matrix.config.r }}
3233

3334
steps:
3435
- uses: actions/checkout@v6

.github/workflows/test-coverage.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ on:
77

88
name: test-coverage.yaml
99

10-
permissions: read-all
10+
permissions:
11+
contents: read
12+
id-token: write
1113

1214
jobs:
1315
test-coverage:
@@ -16,7 +18,7 @@ jobs:
1618
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1719

1820
steps:
19-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v6
2022

2123
- uses: r-lib/actions/setup-r@v2
2224
with:
@@ -45,7 +47,7 @@ jobs:
4547
files: ./cobertura.xml
4648
plugins: noop
4749
disable_search: true
48-
token: ${{ secrets.CODECOV_TOKEN }}
50+
use_oidc: true
4951

5052
- name: Show testthat output
5153
if: always()
@@ -56,7 +58,7 @@ jobs:
5658

5759
- name: Upload test results
5860
if: failure()
59-
uses: actions/upload-artifact@v4
61+
uses: actions/upload-artifact@v7
6062
with:
6163
name: coverage-test-failures
6264
path: ${{ runner.temp }}/package

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ SystemRequirements: pandoc (>= 1.12.3), pandoc-citeproc
3030
Depends:
3131
R (>= 4.1.0)
3232
Imports:
33-
dplyr (>= 0.8.0),
33+
dplyr (>= 1.0.0),
3434
ggplot2 (>= 3.4.0),
3535
ggridges (>= 0.5.5),
3636
glue,
37+
lifecycle,
3738
posterior,
3839
reshape2,
39-
rlang (>= 0.3.0),
40+
rlang (>= 1.0.0),
4041
stats,
4142
tibble (>= 2.0.0),
4243
tidyr,

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,6 @@ importFrom(dplyr,top_n)
226226
importFrom(dplyr,ungroup)
227227
importFrom(dplyr,vars)
228228
importFrom(ggplot2,"%+replace%")
229+
importFrom(lifecycle,deprecate_warn)
230+
importFrom(lifecycle,deprecated)
231+
importFrom(lifecycle,is_present)

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# bayesplot (development version)
22

3+
* Standardize input validation errors in `ppc_km_overlay()` and interpolation helpers to use `rlang::abort()` for consistent error handling.
4+
* Fix assignment-in-call bug in `mcmc_rank_ecdf()` (#).
5+
* Replaced deprecated `dplyr` and `tidyselect` functions (`top_n`, `one_of`, `group_indices`) with their modern equivalents to ensure future compatibility. (#431)
6+
* Documentation added for all exported `*_data()` functions (#209)
7+
* Improved documentation for `binwidth`, `bins`, and `breaks` arguments to clarify they are passed to `ggplot2::geom_area()` and `ggdist::stat_dots()` in addition to `ggplot2::geom_histogram()`
8+
* Improved documentation for `freq` argument to clarify it applies to frequency polygons in addition to histograms
9+
* Fixed test in `test-ppc-distributions.R` that incorrectly used `ppc_dens()` instead of `ppd_dens()` when testing PPD functions
310
* New functions `mcmc_dots` and `mcmc_dots_by_chain` for dot plots of MCMC draws by @behramulukir (#402)
411
* Default to `quantiles=100` for all dot plots by @behramulukir (#402)
512
* Make diagnostic color scale helpers handle `"neff"` and `"neff_ratio"` explicitly, avoiding reliance on partial matching.

R/bayesplot-helpers.R

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,28 @@ plot_bg <- function(on = TRUE, ...) {
446446

447447
#' @rdname bayesplot-helpers
448448
#' @export
449-
#' @param color,size Passed to [ggplot2::element_line()].
450-
#'
451-
grid_lines <- function(color = "gray50", size = 0.2) {
449+
#' @param color,linewidth Passed to [ggplot2::element_line()].
450+
#' @param size `r lifecycle::badge("deprecated")` Use `linewidth` instead.
451+
#'
452+
grid_lines <- function(color = "gray50", linewidth = 0.2, size = deprecated()) {
453+
if (lifecycle::is_present(size)) {
454+
lifecycle::deprecate_warn(
455+
"1.16.0",
456+
"grid_lines(size)",
457+
"grid_lines(linewidth)"
458+
)
459+
linewidth <- size
460+
}
452461
theme(
453-
panel.grid.major = element_line(color = color, linewidth = size),
454-
panel.grid.minor = element_line(color = color, linewidth = size * 0.5)
462+
panel.grid.major = element_line(color = color, linewidth = linewidth),
463+
panel.grid.minor = element_line(color = color, linewidth = linewidth * 0.5)
455464
)
456465
}
457466

458-
grid_lines_y <- function(color = "gray50", size = 0.2) {
467+
grid_lines_y <- function(color = "gray50", linewidth = 0.2) {
459468
theme(
460-
panel.grid.major.y = element_line(color = color, linewidth = size),
461-
panel.grid.minor.y = element_line(color = color, linewidth = size * 0.5)
469+
panel.grid.major.y = element_line(color = color, linewidth = linewidth),
470+
panel.grid.minor.y = element_line(color = color, linewidth = linewidth * 0.5)
462471
)
463472
}
464473

R/bayesplot-package.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#'
66
#' @import ggplot2 stats rlang
77
#' @importFrom dplyr %>% summarise group_by select
8+
#' @importFrom lifecycle deprecated deprecate_warn is_present
89
#'
910
#' @description
1011
#' \if{html}{

R/helpers-gg.R

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ geom_ignore <- function(...) {
2424

2525
#' Add new aesthetic mappings to a list of aesthetic mappings
2626
#'
27-
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes_()`)
28-
#' @param ... additional mappings to add, e.g., `color = ~ parameter`
27+
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes()`)
28+
#' @param ... additional mappings to add using `.data$` syntax
2929
#' @return the updated list
3030
#' @noRd
31-
modify_aes_ <- function(mapping, ...) {
32-
utils::modifyList(mapping, aes_(...))
33-
}
34-
35-
#' Same as `modify_aes_` but using `aes()` instead of `aes_()` (now deprecated).
36-
#' Often `...` will need to contain expression of the form `.data$x` to avoid R cmd check warnings
37-
#' @noRd
3831
modify_aes <- function(mapping, ...) {
3932
utils::modifyList(mapping, aes(...))
4033
}

R/helpers-ppc.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ interpolate_gamma <- function(N, K, prob, L) {
456456
get_interpolation_values <- function(N, K, L, prob) {
457457
for (dim in c("L", "prob")) {
458458
if (all(get(dim) != .gamma_adj[, dim])) {
459-
stop(paste(
459+
abort(paste(
460460
"No precomputed values to interpolate from for '", dim, "' = ",
461461
get(dim),
462462
".\n",
@@ -469,7 +469,7 @@ get_interpolation_values <- function(N, K, L, prob) {
469469
}
470470
vals <- .gamma_adj[.gamma_adj$L == L & .gamma_adj$prob == prob, ]
471471
if (N > max(vals$N)) {
472-
stop(paste(
472+
abort(paste(
473473
"No precomputed values to interpolate from for sample length of ",
474474
N,
475475
".\n",
@@ -480,7 +480,7 @@ get_interpolation_values <- function(N, K, L, prob) {
480480
))
481481
}
482482
if (N < min(vals$N)) {
483-
stop(paste(
483+
abort(paste(
484484
"No precomputed values to interpolate from for sample length of ",
485485
N,
486486
".\n",
@@ -491,7 +491,7 @@ get_interpolation_values <- function(N, K, L, prob) {
491491
))
492492
}
493493
if (K > max(vals[vals$N <= N, ]$K)) {
494-
stop(paste(
494+
abort(paste(
495495
"No precomputed values available for interpolation for 'K' = ",
496496
K,
497497
".\n",
@@ -502,7 +502,7 @@ get_interpolation_values <- function(N, K, L, prob) {
502502
))
503503
}
504504
if (K < min(vals[vals$N <= N, ]$K)) {
505-
stop(paste(
505+
abort(paste(
506506
"No precomputed values available for interpolation for 'K' = ",
507507
K,
508508
".\n",

R/mcmc-diagnostics.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
#'
1919
#' @section Plot Descriptions:
2020
#' \describe{
21+
#' \item{`mcmc_rhat_data()`, `mcmc_neff_data()`}{
22+
#' Data-preparation back ends for the R-hat and effective sample size plots.
23+
#' Users can call these functions directly to obtain the data frame of
24+
#' diagnostic values with rating labels and create custom diagnostic
25+
#' visualizations with **ggplot2**.
26+
#' }
27+
#'
2128
#' \item{`mcmc_rhat()`, `mcmc_rhat_hist()`}{
2229
#' Rhat values as either points or a histogram. Values are colored using
2330
#' different shades (lighter is better). The chosen thresholds are somewhat
@@ -70,7 +77,7 @@
7077
#' (p <- mcmc_acf_bar(x, pars = c("alpha", "beta[1]")))
7178
#'
7279
#' # add horiztonal dashed line at 0.5
73-
#' p + hline_at(0.5, linetype = 2, size = 0.15, color = "gray")
80+
#' p + hline_at(0.5, linetype = 2, linewidth = 0.15, color = "gray")
7481
#' }
7582
#'
7683
#' # fake rhat values to use for demonstration

0 commit comments

Comments
 (0)