Skip to content

Commit fc7c039

Browse files
Replace mentioning of "L'Ecuyer-CMRG RNG" with generic "parallel RNG" to prepare for custom parallel RNGs
1 parent a96f89f commit fc7c039

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

R/001.import_future_functions.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## To be imported from 'future', if available
22
.debug <- NULL
33

4+
make_rng_seeds <- import_future("make_rng_seeds")
5+
next_random_seed <- import_future("next_random_seed")
6+
set_random_seed <- import_future("set_random_seed")
7+
48
## Import private functions from 'future'
59
import_future_functions <- function() {
610
.debug <<- import_future(".debug", mode = "environment", default = new.env(parent = emptyenv()))

R/doFuture.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ function(obj, expr, envir, data) { #nolint
430430
f <- fs[[idx]]
431431
label <- f$label
432432
if (is.null(label)) label <- "<none>"
433-
message <- sprintf("UNRELIABLE VALUE: One of the foreach() iterations (%s) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, use '%%dorng%%' from the 'doRNG' package instead of '%%dopar%%'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, set option 'doFuture.rng.onMisuse' to \"ignore\".", sQuote(label))
433+
message <- sprintf("UNRELIABLE VALUE: One of the foreach() iterations (%s) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, use '%%dorng%%' from the 'doRNG' package instead of '%%dopar%%'. This ensures that proper, parallel-safe random numbers are produced. To disable this check, set option 'doFuture.rng.onMisuse' to \"ignore\".", sQuote(label))
434434
cond$message <- message
435435
if (inherits(cond, "warning")) {
436436
warning(cond)

R/doFuture2.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ doFuture2 <- function(obj, expr, envir, data) { #nolint
172172
if (is.null(seed)) seed <- eval(formals(future)$seed)
173173
if (debug) mdebugf("seed = %s", deparse(seed))
174174

175-
make_rng_seeds <- import_future("make_rng_seeds")
176175
seeds <- make_rng_seeds(nX, seed = seed)
177176

178177
## Future expression (with or without setting the RNG state) and
@@ -184,8 +183,6 @@ doFuture2 <- function(obj, expr, envir, data) { #nolint
184183
mdebug("RNG seeds:")
185184
mstr(seeds)
186185
}
187-
next_random_seed <- import_future("next_random_seed")
188-
set_random_seed <- import_future("set_random_seed")
189186
## If RNG seeds are used (given or generated), make sure to reset
190187
## the RNG state afterward
191188
oseed <- next_random_seed()
@@ -519,7 +516,7 @@ doFuture2 <- function(obj, expr, envir, data) { #nolint
519516
iterations <- seq_to_human(chunk)
520517
iterations <- sprintf("At least one of iterations %s", iterations)
521518
}
522-
message <- sprintf("UNRELIABLE VALUE: %s of the foreach() %%dofuture%% { ... }, part of chunk #%d (%s), unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify foreach() argument '.options.future = list(seed = TRUE)'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, set option 'doFuture.rng.onMisuse' to \"ignore\".", iterations, idx, sQuote(label))
519+
message <- sprintf("UNRELIABLE VALUE: %s of the foreach() %%dofuture%% { ... }, part of chunk #%d (%s), unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify foreach() argument '.options.future = list(seed = TRUE)'. This ensures that proper, parallel-safe random numbers are produced. To disable this check, set option 'doFuture.rng.onMisuse' to \"ignore\".", iterations, idx, sQuote(label))
523520
cond$message <- message
524521
if (inherits(cond, "warning")) {
525522
warning(cond)

R/dofuture_OP.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@
5959
#' workers, and scheduling ("chunking") strategy.
6060
#'
6161
#' RNG reproducibility is achieved by pregenerating the random seeds for all
62-
#' iterations by using L'Ecuyer-CMRG RNG streams. In each
62+
#' iterations by parallel RNG streams. In each
6363
#' iteration, these seeds are set before evaluating the foreach expression.
6464
#' _Note, for large number of iterations this may introduce a large overhead._
6565
#'
6666
#' If `seed = TRUE`, then \code{\link[base:Random]{.Random.seed}}
67-
#' is used if it holds a L'Ecuyer-CMRG RNG seed, otherwise one is created
67+
#' is used if it holds a parallel RNG seed, otherwise one is created
6868
#' randomly.
6969
#'
7070
#' If `seed = FALSE`, it is expected that none of the foreach iterations
@@ -75,9 +75,9 @@
7575
#' whether random numbers were generated or not.
7676
#'
7777
#' As input, `seed` may also take a fixed initial seed (integer),
78-
#' either as a full L'Ecuyer-CMRG RNG seed (vector of 1+6 integers), or
79-
#' as a seed generating such a full L'Ecuyer-CMRG seed. This seed will
80-
#' be used to generated one L'Ecuyer-CMRG RNG stream for each iteration.
78+
#' either as a full parallel RNG seed (vector of 1+6 integers), or
79+
#' as a seed generating such a full seed. This seed will
80+
#' be used to generated one parallel RNG stream for each iteration.
8181
#'
8282
#' An alternative to specifying the `seed` option via `.options.future`,
8383
#' is to use the \code{\link[future:%seed%]{%seed%}} operator. See

R/withDoRNG.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#' risk that those random numbers are not statistically sound and the overall
5050
#' results might be invalid. To fix this, use '%dorng%' from the 'doRNG'
5151
#' package instead of '%dopar%'. This ensures that proper, parallel-safe
52-
#' random numbers are produced via the L'Ecuyer-CMRG method. To disable this
53-
#' check, set option 'doFuture.rng.onMisuse' to "ignore".
52+
#' random numbers are produced. To disable this check, set option
53+
#' 'doFuture.rng.onMisuse' to "ignore".
5454
#' >
5555
#' ```
5656
#'

man/grapes-dofuture-grapes.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/withDoRNG.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)