Skip to content

Commit 2b25a04

Browse files
committed
put back global code
1 parent 4ad8fd9 commit 2b25a04

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

R/tune_cluster.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,15 @@ tune_cluster_loop_iter <- function(split,
326326
load_pkgs(workflow)
327327
load_namespace(control$pkgs)
328328

329+
# After package loading to avoid potential package RNG manipulation
330+
if (!is.null(seed)) {
331+
# `assign()`-ing the random seed alters the `kind` type to L'Ecuyer-CMRG,
332+
# so we have to ensure it is restored on exit
333+
old_kind <- RNGkind()[[1]]
334+
assign(".Random.seed", seed, envir = globalenv())
335+
on.exit(RNGkind(kind = old_kind), add = TRUE)
336+
}
337+
329338
control_parsnip <- parsnip::control_parsnip(verbosity = 0, catch = TRUE)
330339
control_workflow <- workflows::control_workflow(control_parsnip)
331340

tests/testthat/_snaps/tune_cluster.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@
118118
# A tibble: 2 x 4
119119
splits id .metrics .notes
120120
<list> <chr> <list> <list>
121-
1 <split [16/16]> Fold1 <tibble [6 x 5]> <tibble [0 x 3]>
122-
2 <split [16/16]> Fold2 <tibble [6 x 5]> <tibble [0 x 3]>
121+
1 <split [16/16]> Fold1 <tibble [4 x 5]> <tibble [0 x 3]>
122+
2 <split [16/16]> Fold2 <tibble [4 x 5]> <tibble [0 x 3]>
123123

124124
# select_best() and show_best() works
125125

0 commit comments

Comments
 (0)