Skip to content

Commit 1315164

Browse files
Merge branch 'master' into dependence-aware-LOO-PIT
2 parents 496c435 + a86c556 commit 1315164

22 files changed

Lines changed: 542 additions & 81 deletions

.github/workflows/test-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
covr::to_cobertura(cov)
4141
shell: Rscript {0}
4242

43-
- uses: codecov/codecov-action@v5
43+
- uses: codecov/codecov-action@v6
4444
with:
4545
# Fail if error if not on PR, or if on PR and token is given
4646
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ release-prep.R
1616

1717
# vscode/positron/etc settings
1818
.vscode/*
19-
Rplots.pdf
19+
Rplots.pdf

NEWS.md

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

3+
* Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`.
4+
* Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`.
5+
* Added unit tests for `ppc_error_data()` and `ppc_loo_pit_data()` covering output structure, argument handling, and edge cases.
6+
* Added vignette sections demonstrating `*_data()` companion functions for building custom ggplot2 visualizations (#435)
7+
* Extract `drop_singleton_values()` helper in `mcmc_nuts_treedepth()` to remove duplicated filtering logic.
38
* 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.
9+
* Validate equal chain lengths in `validate_df_with_chain()`, reject missing chain labels, and renumber data-frame chain labels internally when converting to arrays.
710
* Added unit tests for previously untested edge cases in `param_range()`, `param_glue()`, and `tidyselect_parameters()` (no-match, partial-match, and negation behavior).
811
* Bumped minimum version for `rstantools` from `>= 1.5.0` to `>= 2.0.0` .
912
* Use `rlang::warn()` and `rlang::inform()` for selected PPC user messages instead of base `warning()` and `message()`.
@@ -18,7 +21,7 @@
1821
* Default to `quantiles=100` for all dot plots by @behramulukir (#402)
1922
* Use `"neff_ratio"` consistently in diagnostic color scale helpers to avoid relying on partial matching of `"neff"`.
2023
* 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()`
24+
* Replace uses of `geom_bar(stat = "identity")` with the more idiomatic ggplot2 form `geom_col()`
2225
* New function `ppc_rootogram_grouped` for grouped rootogram plots by @behramulukir and @jgabry (#419)
2326

2427
# bayesplot 1.15.0
@@ -35,7 +38,7 @@
3538

3639
# bayesplot 1.14.0
3740

38-
* PPC "avg" functions (`ppc_scatter_avg()`, `ppc_error_scatter_avg()`, etc.) gain a `stat` argument
41+
* PPC "avg" functions (`ppc_scatter_avg()`, `ppc_error_scatter_avg()`, etc.) gain a `stat` argument
3942
to set the averaging function. (Suggestion of #348, @kruschke).
4043
* `ppc_error_scatter_avg_vs_x(x = some_expression)` labels the x axis with `some_expression`.
4144
* New quantile dot plot functions `ppc_dots()` and `ppd_dots()` by @behramulukir (#357)
@@ -57,7 +60,7 @@
5760

5861
* Expand checking workflows to more platforms by @andrjohns (#324)
5962
* Skip tests depending on Suggested dependency rstantools if not installed by @MichaelChirico (#325)
60-
* Skip tests depending on Suggested dependency gridExtra if not installed by @MichaelChirico (#326)
63+
* Skip tests depending on Suggested dependency gridExtra if not installed by @MichaelChirico (#326)
6164
* Fix missing legends for unobserved levels in rhat and neff plots (#328)
6265
* Document problems with `ppc_stat` with `stat="mean"` (#329)
6366
* Ensure rank overlay plot starts at 0 even if not all bins present, thanks @sims1253 (#332)

R/helpers-mcmc.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ df_with_chain2array <- function(x) {
247247
#' @param x object to check
248248
#' @return TRUE or FALSE
249249
is_chain_list <- function(x) {
250+
if (length(x) == 0) {
251+
return(FALSE)
252+
}
250253
check1 <- !is.data.frame(x) && is.list(x)
251254
dims <- try(sapply(x, function(chain) length(dim(chain))), silent=TRUE)
252255
if (inherits(dims, "try-error")) {

R/mcmc-diagnostics-nuts.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,7 @@ mcmc_nuts_treedepth <- function(x, lp, chain = NULL, ...) {
369369
yaxis_ticks(FALSE)
370370

371371
violin_lp_data <- data.frame(treedepth, lp = lp$Value)
372-
373-
# Only keep treedepth values that occur more than once for violin plot
374-
value_counts <- table(violin_lp_data$Value)
375-
keep_values <- names(value_counts[value_counts > 1])
376-
violin_lp_data <- violin_lp_data[violin_lp_data$Value %in% keep_values, ]
372+
violin_lp_data <- drop_singleton_values(violin_lp_data, "Value")
377373

378374
violin_lp <-
379375
ggplot(violin_lp_data, aes(x = factor(.data$Value), y = .data$lp)) +
@@ -382,11 +378,7 @@ mcmc_nuts_treedepth <- function(x, lp, chain = NULL, ...) {
382378
bayesplot_theme_get()
383379

384380
violin_accept_stat_data <- data.frame(treedepth, as = accept_stat$Value)
385-
386-
# Only keep treedepth values that occur more than once for violin plot
387-
value_counts <- table(violin_accept_stat_data$Value)
388-
keep_values <- names(value_counts[value_counts > 1])
389-
violin_accept_stat_data <- violin_accept_stat_data[violin_accept_stat_data$Value %in% keep_values, ]
381+
violin_accept_stat_data <- drop_singleton_values(violin_accept_stat_data, "Value")
390382

391383
violin_accept_stat <-
392384
ggplot(violin_accept_stat_data, aes(x = factor(.data$Value), y = .data$as)) +
@@ -572,3 +564,11 @@ chain_violin <-
572564
alpha = alpha
573565
)
574566
}
567+
568+
# Drop rows whose value in `col` appears only once (singletons cannot
569+
# produce a violin density estimate).
570+
drop_singleton_values <- function(df, col) {
571+
counts <- table(df[[col]])
572+
keep <- names(counts[counts > 1])
573+
df[df[[col]] %in% keep, ]
574+
}

tests/testthat/_snaps/ppc-discrete/ppc-rootogram-discrete-bound-distinct-false.svg

Lines changed: 1 addition & 1 deletion
Loading

tests/testthat/_snaps/ppc-discrete/ppc-rootogram-style-discrete-prob-size.svg renamed to tests/testthat/_snaps/ppc-discrete/ppc-rootogram-discrete-prob-size.svg

Lines changed: 1 addition & 1 deletion
Loading

tests/testthat/_snaps/ppc-discrete/ppc-rootogram-grouped-style-discrete-facet-args-list-nrow-2.svg renamed to tests/testthat/_snaps/ppc-discrete/ppc-rootogram-grouped-discrete-facet-args.svg

Lines changed: 1 addition & 1 deletion
Loading

tests/testthat/_snaps/ppc-discrete/ppc-rootogram-grouped-style-discrete-facet-args-list-nrow-2-scales-free.svg renamed to tests/testthat/_snaps/ppc-discrete/ppc-rootogram-grouped-discrete-nrow-2-scales-free.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)