diff --git a/R/ParamSet.R b/R/ParamSet.R index 4dcec206..1ea05ae6 100644 --- a/R/ParamSet.R +++ b/R/ParamSet.R @@ -432,7 +432,7 @@ ParamSet = R6Class("ParamSet", xs_nontune = discard(xs, inherits, "TuneToken") # only had TuneTokens, nothing else to check here. - if (!length(xs_nontune)) { + if (!length(xs_nontune) && !some(xs, is, "InternalTuneToken")) { return(trueret) } } else { diff --git a/tests/testthat/test_to_tune.R b/tests/testthat/test_to_tune.R index 1dca0c35..97caf872 100644 --- a/tests/testthat/test_to_tune.R +++ b/tests/testthat/test_to_tune.R @@ -456,3 +456,11 @@ test_that("internal and aggr", { ) expect_equal(param_set$search_space()$aggr_internal_tuned_values(list(a = list(1, 2, 3))), list(a = -60)) }) + +test_that("cannot mark non-int-tuneable parameters for int tuning", { + p = ps(x = p_int(lower = 0L)) + expect_error( + p$set_values(x = to_tune(upper = 1000, internal = TRUE, aggr = function(x) round(mean(unlist(x))))), + "Trying to assign" + ) +})