From 0a36616db62dcfdc9e223563e7eea013fe7a3222 Mon Sep 17 00:00:00 2001 From: Sebastian Funk Date: Sun, 4 Feb 2024 19:58:15 +0000 Subject: [PATCH] don't use future_lapply for cmdstanr --- R/simulate_infections.R | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/R/simulate_infections.R b/R/simulate_infections.R index ca35d52f7..402a615aa 100644 --- a/R/simulate_infections.R +++ b/R/simulate_infections.R @@ -245,12 +245,18 @@ simulate_infections <- function(estimates, safe_batch <- safely(batch_simulate) + if (backend == "cmdstanr") { + lapply_func <- lapply ## future_lapply can't handle cmdstanr + } else { + lapply_func <- function(...) future_lapply(future.seed = TRUE, ...) + } + ## simulate in batches with_progress({ if (verbose) { p <- progressor(along = batches) } - out <- future_lapply(batches, + out <- lapply_func(batches, function(batch) { if (verbose) { p() @@ -260,8 +266,7 @@ simulate_infections <- function(estimates, shift, dates, batch[[1]], batch[[2]] )[[1]] - }, - future.seed = TRUE + } ) })