Skip to content

Commit

Permalink
put back global code
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Dec 6, 2022
1 parent 4ad8fd9 commit 2b25a04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions R/tune_cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ tune_cluster_loop_iter <- function(split,
load_pkgs(workflow)
load_namespace(control$pkgs)

# After package loading to avoid potential package RNG manipulation
if (!is.null(seed)) {
# `assign()`-ing the random seed alters the `kind` type to L'Ecuyer-CMRG,
# so we have to ensure it is restored on exit
old_kind <- RNGkind()[[1]]
assign(".Random.seed", seed, envir = globalenv())
on.exit(RNGkind(kind = old_kind), add = TRUE)
}

control_parsnip <- parsnip::control_parsnip(verbosity = 0, catch = TRUE)
control_workflow <- workflows::control_workflow(control_parsnip)

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/tune_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
# A tibble: 2 x 4
splits id .metrics .notes
<list> <chr> <list> <list>
1 <split [16/16]> Fold1 <tibble [6 x 5]> <tibble [0 x 3]>
2 <split [16/16]> Fold2 <tibble [6 x 5]> <tibble [0 x 3]>
1 <split [16/16]> Fold1 <tibble [4 x 5]> <tibble [0 x 3]>
2 <split [16/16]> Fold2 <tibble [4 x 5]> <tibble [0 x 3]>

# select_best() and show_best() works

Expand Down

0 comments on commit 2b25a04

Please sign in to comment.