Skip to content

Commit ada278c

Browse files
authored
Merge branch 'master' into add-cmdstanr-to-gha
2 parents 8931efd + 62fce06 commit ada278c

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

.github/workflows/test-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
covr::to_cobertura(cov)
4545
shell: Rscript {0}
4646

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

NEWS.md

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

3+
* Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`.
4+
* Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`.
35
* Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`.
46
* Added unit tests for `ppc_error_data()` and `ppc_loo_pit_data()` covering output structure, argument handling, and edge cases.
57
* Added vignette sections demonstrating `*_data()` companion functions for building custom ggplot2 visualizations (#435)

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/helpers-ppc.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ validate_predictions <- function(predictions, n_obs = NULL) {
7373
}
7474

7575
if (is.integer(predictions)) {
76-
if (nrow(predictions) == 1) {
77-
predictions[1, ] <- as.numeric(predictions[1,, drop = FALSE])
78-
}
79-
else {
80-
predictions <- apply(predictions, 2, as.numeric)
81-
}
76+
storage.mode(predictions) <- "numeric"
8277
}
8378

8479
if (anyNA(predictions)) {

tests/testthat/test-helpers-mcmc.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ test_that("is_chain_list works", {
156156
expect_true(is_chain_list(chainlist))
157157
expect_true(is_chain_list(chainlist1))
158158
expect_true(is_chain_list(chainlist1chain))
159+
expect_false(is_chain_list(list()))
159160
})
160161

161162
test_that("validate_chain_list works", {

0 commit comments

Comments
 (0)