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 + } ) })