Skip to content

Commit c5a85b7

Browse files
authored
Merge branch 'master' into fix/ecdf-geom-step-259
2 parents c610a1c + 83ad3ef commit c5a85b7

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

NEWS.md

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

33
* `ppc_ecdf_overlay()`, `ppc_ecdf_overlay_grouped()`, and `ppd_ecdf_overlay()` now always use `geom_step()`. The `discrete` argument is deprecated.
4+
* Fixed missing `drop = FALSE` in `nuts_params.CmdStanMCMC()`.
45
* Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`.
56
* Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`.
67
* Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`.

R/bayesplot-extractors.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ nuts_params.list <- function(object, pars = NULL, ...) {
175175
nuts_params.CmdStanMCMC <- function(object, pars = NULL, ...) {
176176
arr <- object$sampler_diagnostics()
177177
if (!is.null(pars)) {
178-
arr <- arr[,, pars]
178+
arr <- arr[,, pars, drop = FALSE]
179179
}
180180
out <- reshape2::melt(arr)
181181
colnames(out)[colnames(out) == "variable"] <- "parameter"

tests/testthat/test-extractors.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,12 @@ test_that("cmdstanr methods work", {
136136
ratio <- neff_ratio(fit)
137137
expect_named(head(ratio, 4), c("alpha", "beta[1]", "beta[2]", "beta[3]"))
138138
expect_true(all(ratio > 0))
139+
140+
# https://github.com/stan-dev/bayesplot/pull/535
141+
np_one <- nuts_params(fit, pars = "divergent__")
142+
expect_identical(levels(np_one$Parameter), "divergent__")
143+
expect_true(all(np_one$Parameter == "divergent__"))
144+
expect_equal(range(np_one$Iteration), c(1, 500))
145+
expect_equal(range(np_one$Chain), c(1, 2))
146+
expect_true(all(np_one$Value == 0))
139147
})

0 commit comments

Comments
 (0)