Skip to content

Commit dbf43c9

Browse files
authored
Merge branch 'master' into add-cmdstanr-to-gha
2 parents f6c0c69 + b19e3cd commit dbf43c9

File tree

89 files changed

+4079
-874
lines changed

Some content is hidden

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

89 files changed

+4079
-874
lines changed

.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:
@@ -49,7 +51,7 @@ jobs:
4951
files: ./cobertura.xml
5052
plugins: noop
5153
disable_search: true
52-
token: ${{ secrets.CODECOV_TOKEN }}
54+
use_oidc: true
5355

5456
- name: Show testthat output
5557
if: always()
@@ -60,7 +62,7 @@ jobs:
6062

6163
- name: Upload test results
6264
if: failure()
63-
uses: actions/upload-artifact@v4
65+
uses: actions/upload-artifact@v7
6466
with:
6567
name: coverage-test-failures
6668
path: ${{ runner.temp }}/package

DESCRIPTION

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ Description: Plotting functions for posterior analysis, MCMC diagnostics,
2626
License: GPL (>= 3)
2727
URL: https://mc-stan.org/bayesplot/
2828
BugReports: https://github.com/stan-dev/bayesplot/issues/
29-
SystemRequirements: pandoc (>= 1.12.3), pandoc-citeproc
29+
SystemRequirements: pandoc (>= 1.12.3)
3030
Depends:
3131
R (>= 4.1.0)
3232
Imports:
33-
dplyr (>= 0.8.0),
34-
ggplot2 (>= 3.4.0),
33+
dplyr (>= 1.0.0),
34+
ggplot2 (>= 3.5.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,
@@ -54,7 +55,7 @@ Suggests:
5455
rmarkdown (>= 1.0.0),
5556
rstan (>= 2.17.1),
5657
rstanarm (>= 2.17.4),
57-
rstantools (>= 1.5.0),
58+
rstantools (>= 2.0.0),
5859
scales,
5960
shinystan (>= 2.3.0),
6061
survival,

NAMESPACE

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export(mcmc_dens)
7474
export(mcmc_dens_chains)
7575
export(mcmc_dens_chains_data)
7676
export(mcmc_dens_overlay)
77+
export(mcmc_dots)
78+
export(mcmc_dots_by_chain)
7779
export(mcmc_hex)
7880
export(mcmc_hist)
7981
export(mcmc_hist_by_chain)
@@ -155,6 +157,7 @@ export(ppc_ribbon)
155157
export(ppc_ribbon_data)
156158
export(ppc_ribbon_grouped)
157159
export(ppc_rootogram)
160+
export(ppc_rootogram_grouped)
158161
export(ppc_scatter)
159162
export(ppc_scatter_avg)
160163
export(ppc_scatter_avg_data)
@@ -215,12 +218,14 @@ importFrom(dplyr,inner_join)
215218
importFrom(dplyr,left_join)
216219
importFrom(dplyr,mutate)
217220
importFrom(dplyr,n)
218-
importFrom(dplyr,one_of)
219221
importFrom(dplyr,pull)
220222
importFrom(dplyr,rename)
221223
importFrom(dplyr,select)
224+
importFrom(dplyr,slice_min)
222225
importFrom(dplyr,summarise)
223-
importFrom(dplyr,top_n)
224226
importFrom(dplyr,ungroup)
225227
importFrom(dplyr,vars)
226228
importFrom(ggplot2,"%+replace%")
229+
importFrom(lifecycle,deprecate_warn)
230+
importFrom(lifecycle,deprecated)
231+
importFrom(lifecycle,is_present)

NEWS.md

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

3+
* Eliminate redundant data processing in `mcmc_areas_data()` by reusing the prepared MCMC array for both interval and density computation.
4+
* Validate equal chain lengths in `validate_df_with_chain()`, reject missing
5+
chain labels, and renumber data-frame chain labels internally when converting
6+
to arrays.
7+
* Added unit tests for previously untested edge cases in `param_range()`, `param_glue()`, and `tidyselect_parameters()` (no-match, partial-match, and negation behavior).
8+
* Bumped minimum version for `rstantools` from `>= 1.5.0` to `>= 2.0.0` .
9+
* Use `rlang::warn()` and `rlang::inform()` for selected PPC user messages instead of base `warning()` and `message()`.
10+
* Standardize input validation errors in `ppc_km_overlay()` and interpolation helpers to use `rlang::abort()` for consistent error handling.
11+
* Fix assignment-in-call bug in `mcmc_rank_ecdf()` (#).
12+
* Replaced deprecated `dplyr` and `tidyselect` functions (`top_n`, `one_of`, `group_indices`) with their modern equivalents to ensure future compatibility. (#431)
13+
* Documentation added for all exported `*_data()` functions (#209)
14+
* 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()`
15+
* Improved documentation for `freq` argument to clarify it applies to frequency polygons in addition to histograms
16+
* Fixed test in `test-ppc-distributions.R` that incorrectly used `ppc_dens()` instead of `ppd_dens()` when testing PPD functions
17+
* New functions `mcmc_dots` and `mcmc_dots_by_chain` for dot plots of MCMC draws by @behramulukir (#402)
18+
* Default to `quantiles=100` for all dot plots by @behramulukir (#402)
19+
* Use `"neff_ratio"` consistently in diagnostic color scale helpers to avoid relying on partial matching of `"neff"`.
20+
* Replace `expand = c(mult, add)` with `ggplot2::expansion()` helper in scale functions for consistency with ggplot2 >= 3.3.0 style.
21+
* Replace uses of `geom_bar(stat = "identity")` with the more idiomatic ggplot2 form `geom_col()`
22+
* New function `ppc_rootogram_grouped` for grouped rootogram plots by @behramulukir and @jgabry (#419)
23+
324
# bayesplot 1.15.0
425

526
* Add `shape` argument to `mcmc_scatter` by @behramulukir (#375)

R/bayesplot-colors.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ color_scheme_view <- function(scheme = NULL) {
189189

190190
#' @export
191191
print.bayesplot_scheme <- function(x, ...) {
192-
tab <- data.frame(unlist(x, use.names = FALSE), stringsAsFactors = FALSE)
192+
tab <- data.frame(unlist(x, use.names = FALSE))
193193
colnames(tab) <- attr(x, "scheme_name") %||% "hex_color"
194194
print(tab, ...)
195195
}
@@ -222,9 +222,8 @@ plot_scheme <- function(scheme = NULL) {
222222
)
223223

224224
ggplot(color_data, aes(x = .data$name, y = .data$value, fill = .data$group)) +
225-
geom_bar(
225+
geom_col(
226226
width = .5,
227-
stat = "identity",
228227
color = "white",
229228
linewidth = 0.1
230229
) +

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: 4 additions & 11 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
}
@@ -44,10 +37,10 @@ modify_aes <- function(mapping, ...) {
4437
facet_wrap_parsed <- function(...) {
4538
facet_wrap(..., labeller = label_parsed)
4639
}
47-
dont_expand_y_axis <- function(expand = c(0,0)) {
40+
dont_expand_y_axis <- function(expand = expansion(0, 0)) {
4841
scale_y_continuous(expand = expand)
4942
}
50-
dont_expand_x_axis <- function(expand = c(0,0)) {
43+
dont_expand_x_axis <- function(expand = expansion(0, 0)) {
5144
scale_x_continuous(expand = expand)
5245
}
5346
dont_expand_axes <- function() {

R/helpers-mcmc.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ validate_df_with_chain <- function(x) {
210210
x$chain <- NULL
211211
}
212212
x$Chain <- as.integer(x$Chain)
213+
if (anyNA(x$Chain)) {
214+
abort("Chain values must not be NA.")
215+
}
216+
rows_per_chain <- table(x$Chain)
217+
if (length(unique(rows_per_chain)) != 1) {
218+
abort("All chains must have the same number of iterations.")
219+
}
213220
x
214221
}
215222

@@ -218,11 +225,14 @@ validate_df_with_chain <- function(x) {
218225
df_with_chain2array <- function(x) {
219226
x <- validate_df_with_chain(x)
220227
chain <- x$Chain
228+
# Renumber arbitrary chain labels to the contiguous 1:N indices used internally.
229+
chain <- match(chain, sort(unique(chain)))
221230
n_chain <- length(unique(chain))
222231
a <- x[, !colnames(x) %in% "Chain", drop = FALSE]
223232
parnames <- colnames(a)
224233
a <- as.matrix(a)
225-
x <- array(NA, dim = c(ceiling(nrow(a) / n_chain), n_chain, ncol(a)))
234+
n_iter <- nrow(a) %/% n_chain
235+
x <- array(NA, dim = c(n_iter, n_chain, ncol(a)))
226236
for (j in seq_len(n_chain)) {
227237
x[, j, ] <- a[chain == j,, drop=FALSE]
228238
}

0 commit comments

Comments
 (0)