Skip to content

Commit

Permalink
Merge pull request #414 from mlr-org/fix/check-int-tune
Browse files Browse the repository at this point in the history
Fix check on int-tuning
  • Loading branch information
sebffischer authored Oct 18, 2024
2 parents 87cb68d + 6b139cc commit dfe06da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/ParamSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test_to_tune.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
})

0 comments on commit dfe06da

Please sign in to comment.