diff --git a/NEWS.md b/NEWS.md index 474ccbb3..f2649de4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ - `WeibSurvOS` now does not return an error for large values of t. - `PWCSurvOS` now does not return an error for large values of t. It also no longer returns values larger than 1. It is significantly faster, based on a closed form calculation instead of numerical integration. - `getSimulatedData` now also works when there are no transitions from progression to death, similarly for `getOneClinicalTrial` (which now warns if there are no such transitions at all). +- `corPFSOS` now undoes the `future` plan upon function exit. ### Miscellaneous diff --git a/R/corPFSOS.R b/R/corPFSOS.R index 25e16974..38d71320 100644 --- a/R/corPFSOS.R +++ b/R/corPFSOS.R @@ -314,7 +314,8 @@ corPFSOS <- function(data, transition, bootstrap = TRUE, bootstrap_n = 100, conf trans <- estimateParams(data, transition) res <- list("corPFSOS" = corTrans(trans)) if (bootstrap) { - future::plan(future::multisession, workers = max(1, parallelly::availableCores() - 1)) + oplan <- future::plan(future::multisession, workers = parallelly::availableCores(omit = 1)) + on.exit(future::plan(oplan), add = TRUE) ids <- lapply(1:bootstrap_n, function(x) sample(seq_len(nrow(data)), nrow(data), replace = TRUE)) corBootstrap <- furrr::future_map_dbl(ids, ~ { furrr::furrr_options(