Skip to content

Commit 2ad7ef4

Browse files
committed
Keep PR focused on empty chain list fix
1 parent 852fae1 commit 2ad7ef4

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

R/bayesplot-extractors.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ nuts_params.stanreg <-
145145
#' @export
146146
#' @method nuts_params list
147147
nuts_params.list <- function(object, pars = NULL, ...) {
148-
if (!all(vapply(object, is.matrix, logical(1)))) {
148+
if (!all(sapply(object, is.matrix))) {
149149
abort("All list elements should be matrices.")
150150
}
151151

R/bayesplot_grid.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ is_bayesplot_grid <- function(x) {
131131
}
132132

133133
all_ggplot <- function(x) {
134-
all(vapply(x, inherits, logical(1), what = "ggplot"))
134+
all(sapply(x, "inherits", what = "ggplot"))
135135
}
136136

137137
#' @export

R/helpers-mcmc.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ is_chain_list <- function(x) {
251251
return(FALSE)
252252
}
253253
check1 <- !is.data.frame(x) && is.list(x)
254-
dims <- try(vapply(x, function(chain) length(dim(chain)), integer(1)), silent=TRUE)
254+
dims <- try(sapply(x, function(chain) length(dim(chain))), silent=TRUE)
255255
if (inherits(dims, "try-error")) {
256256
return(FALSE)
257257
}
@@ -271,7 +271,7 @@ validate_chain_list <- function(x) {
271271
}
272272
}
273273
if (n_chain > 1) {
274-
n_iter <- vapply(x, nrow, integer(1))
274+
n_iter <- sapply(x, nrow)
275275
same_iters <- length(unique(n_iter)) == 1
276276
if (!same_iters) {
277277
abort("Each chain should have the same number of iterations.")
@@ -302,7 +302,7 @@ chain_list2array <- function(x) {
302302
n_iter <- nrow(x[[1]])
303303
param_names <- colnames(x[[1]])
304304
} else {
305-
n_iter <- vapply(x, nrow, integer(1))
305+
n_iter <- sapply(x, nrow)
306306
cnames <- sapply(x, colnames)
307307
param_names <- if (is.array(cnames))
308308
cnames[, 1] else cnames
@@ -437,7 +437,7 @@ apply_transformations.array <- function(x, ..., transformations = list()) {
437437

438438
rename_transformed_pars <- function(pars, transformations) {
439439
stopifnot(is.character(pars), is.list(transformations))
440-
has_names <- vapply(transformations, is.character, logical(1))
440+
has_names <- sapply(transformations, is.character)
441441
if (any(has_names)) {
442442
nms <- names(which(has_names))
443443
for (nm in nms) {

R/mcmc-scatterplots.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pairs_style_np <-
541541
pairs_condition <- function(chains = NULL, draws = NULL, nuts = NULL) {
542542
.ignore_args <- function(..., why = NULL) {
543543
dots <- list(...)
544-
nms <- names(dots)[!vapply(dots, is.null, logical(1))]
544+
nms <- names(dots)[!sapply(dots, is.null)]
545545
if (length(nms)) {
546546
inform(paste0(
547547
"The following specified arguments were ignored by 'pairs_condition' ",

R/ppc-censoring.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ ppc_km_overlay <- function(
167167
fsf <- fortify(sf)
168168
if(any(grepl("add_group", levels(fsf$strata)))){
169169
strata_split <- strsplit(as.character(fsf$strata), split = ", add_group:")
170-
fsf$strata <- as.factor(vapply(strata_split, "[[", character(1), 1))
171-
fsf$group <- as.factor(vapply(strata_split, "[[", character(1), 2))
170+
fsf$strata <- as.factor(sapply(strata_split, "[[", 1))
171+
fsf$group <- as.factor(sapply(strata_split, "[[", 2))
172172
}
173173

174174
fsf$is_y_color <- as.factor(sub("\\[rep\\] \\(.*$", "rep", sub("^italic\\(y\\)", "y", fsf$strata)))

0 commit comments

Comments
 (0)