alexpkeil1/qgcomp

future::plan(): better approach + don't use 'transparent'

HenrikBengtsson opened this issue · 3 comments

Hi,

I see that you use for instance:

qgcomp/R/base_surv.R

Lines 626 to 632 in 95e0b74

if(parplan) future::plan(strategy = future::multisession)
bootsamps <- future.apply::future_lapply(X=seq_len(B), FUN=psi.only,
f=newform, qdata=qdata, intvals=intvals,
expnms=expnms, degree=degree, nids=nids, id=id,
future.seed=TRUE,
weights=qdata$weights, MCsize=MCsize, ...)
if(parplan) future::plan(strategy = future::transparent)

Please use the following instead:

if (parplan) {
  oplan <- future::plan(strategy = future::multisession)
  on.exit(plan(oplan), add = TRUE)
}

This is the proper way to do it, cf. help("plan", package = "future"). It also avoids using transparent, which should not be used in package code and will eventually be deprecated.

Fixed in 5519045

FYI, transparent is also used in the vignette, cf. https://github.com/alexpkeil1/qgcomp/search?q=transparent

Fixed in e742d51