diff --git a/R/ParamSetCollection.R b/R/ParamSetCollection.R index e288ba6c..0e18777d 100644 --- a/R/ParamSetCollection.R +++ b/R/ParamSetCollection.R @@ -303,12 +303,12 @@ ParamSetCollection = R6Class("ParamSetCollection", inherit = ParamSet, in_tune_fn = cargo$in_tune_fn - set_ids = info$ids + prefixed_set_ids = private$.add_name_prefix(prefix, info$ids) cargo$in_tune_fn = crate(function(domain, param_vals) { - param_vals = param_vals[names(param_vals) %in% private$.add_name_prefix(prefix, set_ids)] + param_vals = param_vals[names(param_vals) %in% prefixed_set_ids] names(param_vals) = gsub(sprintf("^\\Q%s.\\E", prefix), "", names(param_vals)) in_tune_fn(domain, param_vals) - }, in_tune_fn, prefix, set_ids) + }, in_tune_fn, prefix, prefixed_set_ids) if (length(cargo$disable_in_tune)) { cargo$disable_in_tune = set_names( diff --git a/tests/testthat/test_ParamSetCollection.R b/tests/testthat/test_ParamSetCollection.R index 7f3dbaf1..50135fd5 100644 --- a/tests/testthat/test_ParamSetCollection.R +++ b/tests/testthat/test_ParamSetCollection.R @@ -376,7 +376,7 @@ test_that("PSC postfix", { ps3 = ps(x.y = p_fct(c("a", "b"))) ps4 = ps(y.x = p_lgl()) - psc = ParamSetCollection$new(list(y = ps1, z = ps2), postfix = TRUE) + psc = ParamSetCollection$new(list(y = ps1, z = ps2), postfix_names = TRUE) expect_equal(psc$ids(), c("x.y", "x.z")) @@ -432,14 +432,14 @@ test_that("PSC postfix", { expect_equal(ps4$values, named_list()) # mixed with / without names - psc = ParamSetCollection$new(list(y = ps1, ps4), postfix = TRUE) + psc = ParamSetCollection$new(list(y = ps1, ps4), postfix_names = TRUE) expect_equal(psc$ids(), c("x.y", "y.x")) psc$values$x.y = 1 expect_equal(psc$values, list(x.y = 1)) psc$values$y.x = TRUE expect_equal(psc$values, list(x.y = 1, y.x = TRUE)) expect_equal(ps1$values$x, 1) - expect_equal(ps4$values$y, TRUE) + expect_equal(ps4$values$y.x, TRUE) ps4$extra_trafo = function(x, param_set) { x$zzz = 888 @@ -449,10 +449,10 @@ test_that("PSC postfix", { expect_equal(psc$trafo(list()), list(x.z.y = 999, zzz = 888)) # x.y generated twice here - expect_error(ParamSetCollection$new(list(y = ps1, ps3), postfix = TRUE), "would contain duplicated parameter.* x.y") + expect_error(ParamSetCollection$new(list(y = ps1, ps3), postfix_names = TRUE), "would contain duplicated parameter.* x.y") # don't get confused when no names are given - psc = ParamSetCollection$new(list(ps3, ps4), postfix = TRUE) + psc = ParamSetCollection$new(list(ps3, ps4), postfix_names = TRUE) expect_equal(psc$ids(), c("x.y", "y.x")) psc$values$x.y = "a"