Skip to content
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

Preserve state of random number generator in .onAttach() #954

Closed
TimTaylor opened this issue Mar 12, 2024 · 1 comment
Closed

Preserve state of random number generator in .onAttach() #954

TimTaylor opened this issue Mar 12, 2024 · 1 comment

Comments

@TimTaylor
Copy link

Currently .onAttach() will change the state of a users random number generator:

forecast/R/attach.R

Lines 1 to 2 in d143826

.onAttach <- function(...) {
if (!interactive() || stats::runif(1) > 0.2) return()

Not a bug per se but would you consider a change to preserve it?

For reference I believe {ggplot2} was updated to use withr::with_preserve_seed() for this reason.

Motivate by this thread https://fosstodon.org/@henrikbengtsson@mastodon.social/112079393660379008

@mitchelloharawild
Copy link
Collaborator

Thanks for the suggestion, I've created a PR (#955) for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants