Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mlr-org/bbotk into main
Browse files Browse the repository at this point in the history
  • Loading branch information
be-marc committed Sep 13, 2021
2 parents 75d2610 + 2d1812b commit 4cbbfb0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions tests/testthat/test_Objective.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ test_that("check_values flag works", {
obj = ObjectiveTestEval$new(domain = PS_2D, codomain = FUN_2D_CODOMAIN,
check_values = TRUE)
expect_error(obj$eval(list(x1 = 2, x2 = 1)),
"Assertion on 'xs' failed: x1: Element 1 is not <= 1.", fixed = TRUE)
"<= 1.", fixed = TRUE)

ObjectiveTestEvalMany = R6Class("ObjectiveTestEvalMany",
inherit = Objective,
Expand All @@ -193,7 +193,7 @@ test_that("check_values flag works", {
obj = ObjectiveTestEvalMany$new(domain = PS_2D, check_values = TRUE)
xs = list(x1 = 2, x2 = 1)
expect_error(obj$eval(list(x1 = 2, x2 = 1)),
"Assertion on 'xs' failed: x1: Element 1 is not <= 1.", fixed = TRUE)
"<= 1.", fixed = TRUE)
})

test_that("check_values = TRUE with extra output works", {
Expand Down Expand Up @@ -223,15 +223,15 @@ test_that("check_values = TRUE with extra output works", {

test_that("assertion on overlapping and reserved names works", {
expect_error(Objective$new(domain = ps(x = p_lgl()), codomain = ps(x = p_dbl(tags = "maximize"))),
regexp = "Assertion on 'self$domain$ids()' failed: Must be disjunct from (x).",
regexp = "disjunct from (x).",
fixed = TRUE)

expect_error(Objective$new(domain = ps(batch_nr = p_lgl()), codomain = ps(x = p_dbl(tags = "maximize"))),
regexp = "Assertion on 'self$domain$ids()' failed: Must be disjunct from (x_domain,timestamp,batch_nr).",
regexp = "disjunct from (x_domain,timestamp,batch_nr).",
fixed = TRUE)

expect_error(Objective$new(domain = ps(x = p_lgl()), codomain = ps(timestamp = p_dbl(tags = "maximize"))),
regexp = "Assertion on 'self$codomain$ids()' failed: Must be disjunct from (x_domain,timestamp,batch_nr).",
regexp = "disjunct from (x_domain,timestamp,batch_nr).",
fixed = TRUE)
})

Expand Down Expand Up @@ -317,5 +317,5 @@ test_that("Objective works with constants", {
expect_equal(objective$eval(list(x = 1)), list(y = 2))
expect_equal(objective$eval(list(x = 0)), list(y = 1))
expect_equal(objective$eval_many(list(list(x = 1), list(x = 0))), data.table(y = c(2, 1)))
expect_equal(objective$eval_dt(data.table(x = c(1, 0))), data.table(y = c(2, 1)))
})
expect_equal(objective$eval_dt(data.table(x = c(1, 0))), data.table(y = c(2, 1)))
})
6 changes: 3 additions & 3 deletions tests/testthat/test_OptimInstanceSingleCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ test_that("OptimInstaceSingleCrit does not work with codomain > 1", {
test_that("OptimInstanceSingleCrit$eval_batch() throws and error if columns are missing", {
inst = MAKE_INST_2D(20L)
expect_error(inst$eval_batch(data.table(x1= 0)),
regexp = "Assertion on 'colnames(xdt)' failed: Must include the elements {x1,x2}.",
regexp = "include the elements {x1,x2}.",
fixed = TRUE)
})

test_that("domain, search_space and TuneToken work", {

domain = ps(
x1 = p_dbl(-10, 10),
x2 = p_dbl(-5, 5)
Expand All @@ -159,7 +159,7 @@ test_that("domain, search_space and TuneToken work", {

# search_space and domain
search_space = ps(
x1 = p_dbl(-10, 10)
x1 = p_dbl(-10, 10)
)

instance = OptimInstanceSingleCrit$new(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_OptimizerDesignPoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ test_that("OptimizerDesignPoints", {

design = data.table(x1 = c(2), x2 = c(2))
expect_error(test_optimizer_2d("design_points", design = design, term_evals = 10L, real_evals = 3),
"Assertion on 'pv$design' failed: x1: Element 1 is not <= 1", fixed = TRUE)
"<= 1", fixed = TRUE)
})

0 comments on commit 4cbbfb0

Please sign in to comment.