Skip to content

Commit 8931efd

Browse files
authored
Merge branch 'master' into add-cmdstanr-to-gha
2 parents dbf43c9 + 94a2ac5 commit 8931efd

19 files changed

+536
-79
lines changed

.gitignore

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

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

NEWS.md

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

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

2426
# bayesplot 1.15.0
@@ -35,7 +37,7 @@
3537

3638
# bayesplot 1.14.0
3739

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

5860
* Expand checking workflows to more platforms by @andrjohns (#324)
5961
* 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)
62+
* Skip tests depending on Suggested dependency gridExtra if not installed by @MichaelChirico (#326)
6163
* Fix missing legends for unobserved levels in rhat and neff plots (#328)
6264
* Document problems with `ppc_stat` with `stat="mean"` (#329)
6365
* Ensure rank overlay plot starts at 0 even if not all bins present, thanks @sims1253 (#332)

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)