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

Setting seed in cvfit should not affect global seed #66

Open
pbreheny opened this issue Apr 7, 2023 · 0 comments
Open

Setting seed in cvfit should not affect global seed #66

pbreheny opened this issue Apr 7, 2023 · 0 comments

Comments

@pbreheny
Copy link

pbreheny commented Apr 7, 2023

This line in L0Learn.cvfit() introduces unintended side effects:

set.seed(seed)

In particular, it affects the RNG seed in the global environment so that if, say, someone is carrying out a simulation and calls L0Learn.cvfit(), it can throw off the whole simulation.

Better to do something like this:

original_seed <- .GlobalEnv$.Random.seed
on.exit(.GlobalEnv$.Random.seed <- original_seed)
set.seed(seed)
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

1 participant