Skip to content

Commit 1d7bb1b

Browse files
authored
Merge pull request #543 from aloctavodia/test
Fix tests: set conditional parallel
2 parents f13e692 + 3fa2bbf commit 1d7bb1b

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

vignettes/latent.Rmd

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,12 @@ The message concerning `latent_ilink` can be safely ignored here (the internal d
555555

556556
Run `cv_varsel()`:
557557
```{r weibull_cvvs}
558-
doParallel::registerDoParallel(ncores)
558+
# For running projpred's CV in parallel (see cv_varsel()'s argument `parallel`):
559+
# Note: Parallel processing is disabled during package building to avoid issues
560+
use_parallel <- FALSE # Set to TRUE for actual parallel processing
561+
if (use_parallel) {
562+
doParallel::registerDoParallel(ncores)
563+
}
559564
cvvs_weib <- cv_varsel(
560565
refm_weib,
561566
### Only for the sake of speed (not recommended in general):
@@ -564,13 +569,16 @@ cvvs_weib <- cv_varsel(
564569
nterms_max = 11,
565570
nclusters_pred = 20,
566571
###
567-
parallel = TRUE,
572+
parallel = use_parallel,
568573
### In interactive use, we recommend not to deactivate the verbose mode:
569574
verbose = 0
570575
###
571576
)
572-
doParallel::stopImplicitCluster()
573-
foreach::registerDoSEQ()
577+
# Tear down the CV parallelization setup:
578+
if (use_parallel) {
579+
doParallel::stopImplicitCluster()
580+
foreach::registerDoSEQ()
581+
}
574582
```
575583
In this case, we will ignore the warnings about high Pareto-$\hat{k}$ values because we chose quite rough settings (e.g., only 2 MCMC chains) in this vignette (for technical reasons).
576584
We will also ignore the warning that SIS is used (instead of PSIS) because this is due to `nclusters_pred = 20` which we used only to speed up the building of the vignette.
@@ -688,7 +696,12 @@ The message concerning `latent_ilink` can be safely ignored here (the internal d
688696

689697
Run `cv_varsel()`:
690698
```{r lognormal_cvvs}
691-
doParallel::registerDoParallel(ncores)
699+
# For running projpred's CV in parallel (see cv_varsel()'s argument `parallel`):
700+
# Note: Parallel processing is disabled during package building to avoid issues
701+
use_parallel <- FALSE # Set to TRUE for actual parallel processing
702+
if (use_parallel) {
703+
doParallel::registerDoParallel(ncores)
704+
}
692705
cvvs_lnorm <- cv_varsel(
693706
refm_lnorm,
694707
### Only for the sake of speed (not recommended in general):
@@ -697,13 +710,16 @@ cvvs_lnorm <- cv_varsel(
697710
nterms_max = 11,
698711
nclusters_pred = 20,
699712
###
700-
parallel = TRUE,
713+
parallel = use_parallel,
701714
### In interactive use, we recommend not to deactivate the verbose mode:
702715
verbose = 0
703716
###
704717
)
705-
doParallel::stopImplicitCluster()
706-
foreach::registerDoSEQ()
718+
# Tear down the CV parallelization setup:
719+
if (use_parallel) {
720+
doParallel::stopImplicitCluster()
721+
foreach::registerDoSEQ()
722+
}
707723
```
708724
In this case, we will ignore the warnings about high Pareto-$\hat{k}$ values because we chose quite rough settings (e.g., only 2 MCMC chains) in this vignette (for technical reasons).
709725
We will also ignore the warning that SIS is used (instead of PSIS) because this is due to `nclusters_pred = 20` which we used only to speed up the building of the vignette.

0 commit comments

Comments
 (0)