-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
with_rng_version() would be nice #90
Comments
I'll probably add an implementation to igraph tomorrow, because they make me fix this.... |
Here is what I wrote: with_rng_version <- function(version, expr) {
orig <- RNGkind()
on.exit(do.call(RNGkind, as.list(orig)), add = TRUE)
suppressWarnings(RNGversion(version))
expr
}
local_rng_version <- function(version, .local_envir = parent.frame()) {
orig <- RNGkind()
defer(do.call(RNGkind, as.list(orig)), envir = .local_envir)
suppressWarnings(RNGversion(version))
orig
} I can submit a PR if you want to have this in withr. |
A pr would be great! |
gaborcsardi
added a commit
that referenced
this issue
May 3, 2019
`with_rng_version()` and `local_rng_version()`. Closes #90.
Merged
jimhester
pushed a commit
that referenced
this issue
May 3, 2019
`with_rng_version()` and `local_rng_version()`. Closes #90.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To ease fixing the new RNG madness in 3.6.0.
The text was updated successfully, but these errors were encountered: