Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# bayesplot (development version)

* Fixed missing `drop = FALSE` in `nuts_params.CmdStanMCMC()`.
* Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`.
* Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`.
* Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`.
Expand Down
2 changes: 1 addition & 1 deletion R/bayesplot-extractors.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ nuts_params.list <- function(object, pars = NULL, ...) {
nuts_params.CmdStanMCMC <- function(object, pars = NULL, ...) {
arr <- object$sampler_diagnostics()
if (!is.null(pars)) {
arr <- arr[,, pars]
arr <- arr[,, pars, drop = FALSE]
}
out <- reshape2::melt(arr)
colnames(out)[colnames(out) == "variable"] <- "parameter"
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-extractors.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,12 @@ test_that("cmdstanr methods work", {
ratio <- neff_ratio(fit)
expect_named(head(ratio, 4), c("alpha", "beta[1]", "beta[2]", "beta[3]"))
expect_true(all(ratio > 0))

# https://github.com/stan-dev/bayesplot/pull/535
np_one <- nuts_params(fit, pars = "divergent__")
expect_identical(levels(np_one$Parameter), "divergent__")
expect_true(all(np_one$Parameter == "divergent__"))
expect_equal(range(np_one$Iteration), c(1, 500))
expect_equal(range(np_one$Chain), c(1, 2))
expect_true(all(np_one$Value == 0))
})
Loading