Skip to content

Commit 852fae1

Browse files
committed
Merge branch 'refactor/sapply-to-vapply-type-safety' of https://github.com/utkarshpawade/bayesplot into pr/517
2 parents 0bb70dd + bcd733e commit 852fae1

4 files changed

Lines changed: 6 additions & 2 deletions

File tree

.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 }}

NEWS.md

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

3-
* Replace 9 uses of `sapply()` with `vapply()` to enforce return types and prevent silent `list()` returns on zero-length input.
3+
* Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`.
44
* Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`.
55
* Added unit tests for `ppc_error_data()` and `ppc_loo_pit_data()` covering output structure, argument handling, and edge cases.
66
* 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(vapply(x, function(chain) length(dim(chain)), integer(1)), silent=TRUE)
252255
if (inherits(dims, "try-error")) {

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)