Closed HenrikBengtsson closed 4 years ago
This warning appears only with plan(sequential)
.
Aha. It is not any of the future packages that updated the RNG kind, it is actually doRNG itself that sets it in the same main global environment that is checked when we run in sequential mode. The same would have happened with:
foreach::registerDoSEQ()
if it would be for doRNG is hardcoded to ignore that case;
rng_type_changed <- !identical(RNGtype(), RNGtype(RNG.old))
known_changing_cases <- is.null(dp) || dp=='doSEQ' || dp=='doMPI'
if( known_changing_cases || rng_type_changed){
if( rng_type_changed && !known_changing_cases ){
warning("Foreach loop had changed the current RNG type: RNG was restored to same type, next state")
}else{
message("* Detected known RNG side effect: ", dp)
}
message("* Restoring RNG as after RNG sequence generation")
if( verbose ) showRNG(RNG.old, indent = " -")
RNGseed(RNG.old)
message("OK")
}
Requested doFuture to be added to the doRNG ignore list (https://github.com/renozao/doRNG/issues/14).
doRNG now had as an option for registering doFuture to be a recognized backend.
Using doFuture no longer produces that warning by having registerDoFuture()
set option doRNG.rng_change_warning_skip
introduced in doRNG (>= 1.8.2);
library(foreach)
doFuture::registerDoFuture()
library(doRNG)
y <- foreach(x = 1:2) %dorng% { rnorm(1); x }
Issue
With
we get a warning if we do:
or
Workaround
Setting the RNG kind to "L'Ecuyer-CMRG" upfront avoids this warning;
Session info
Troubleshooting / Action
This most likely originates from the future package.