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

Add withr preserve seed for .onAttach random tip #955

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Imports:
timeDate,
tseries,
urca,
withr,
zoo
Suggests:
forecTheta,
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# forecast (development version)
* Prevented RNG state changing when the package is attached (#954, #955).

# forecast 8.22.0
* hfitted now much faster for ARIMA models (danigiro, #949)
Expand Down
4 changes: 2 additions & 2 deletions R/attach.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.onAttach <- function(...) {
if (!interactive() || stats::runif(1) > 0.2) return()
if (!interactive() || withr::with_preserve_seed(stats::runif(1)) > 0.2) return()

tips <- c(
"Use suppressPackageStartupMessages() to eliminate package startup messages.",
Expand All @@ -9,7 +9,7 @@
"Want to stay up-to-date? Read the Hyndsight blog:\n https://robjhyndman.com/hyndsight/",
"Want to meet other forecasters? Join the International Institute of Forecasters:\n http://forecasters.org/"
)
tip <- sample(tips, 1)
tip <- withr::with_preserve_seed(sample(tips, 1))
msg <- paste("This is forecast", packageVersion("forecast"), "\n ", tip)
packageStartupMessage(msg)
}
Expand Down
Loading