robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.1k stars 340 forks source link

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

Closed TimTaylor closed 2 months ago

TimTaylor commented 3 months ago

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

https://github.com/robjhyndman/forecast/blob/d1438266bc19c0613cd39ebbad7a1a3f8497cd5f/R/attach.R#L1-L2

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 commented 3 months ago

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