Skip to content

Commit

Permalink
don't use future_lapply for cmdstanr
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Feb 4, 2024
1 parent ced14ad commit 8c789c4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/simulate_infections.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -260,8 +266,7 @@ simulate_infections <- function(estimates,
shift, dates, batch[[1]],
batch[[2]]
)[[1]]
},
future.seed = TRUE
}
)
})

Expand Down

0 comments on commit 8c789c4

Please sign in to comment.