Skip to content

Commit e62e47e

Browse files
committed
test: helper
1 parent 2c0d558 commit e62e47e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/testthat/helper.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ FUN_1D = function(xs) {
99
list(y = as.numeric(xs)^2)
1010
}
1111
FUN_1D_CODOMAIN = ps(y = p_dbl(tags = "minimize"))
12-
OBJ_1D = ObjectiveRFun$new(fun = FUN_1D, domain = PS_1D, codomain = FUN_1D_CODOMAIN, properties = "single-crit")
12+
OBJ_1D = bbotk::ObjectiveRFun$new(fun = FUN_1D, domain = PS_1D, codomain = FUN_1D_CODOMAIN, properties = "single-crit")
1313

1414
FUN_1D_2 = function(xs) {
1515
list(y1 = as.numeric(xs)^2, y2 = - sqrt(abs(as.numeric(xs))))
1616
}
1717
FUN_1D_2_CODOMAIN = ps(y1 = p_dbl(tags = "minimize"), y2 = p_dbl(tags = "minimize"))
18-
OBJ_1D_2 = ObjectiveRFun$new(fun = FUN_1D_2, domain = PS_1D, codomain = FUN_1D_2_CODOMAIN, properties = "multi-crit")
18+
OBJ_1D_2 = bbotk::ObjectiveRFun$new(fun = FUN_1D_2, domain = PS_1D, codomain = FUN_1D_2_CODOMAIN, properties = "multi-crit")
1919

2020
# Simple 1D Functions with noise
2121
FUN_1D_NOISY = function(xs) {
2222
list(y = as.numeric(xs)^2 + rnorm(1, sd = 0.5))
2323
}
24-
OBJ_1D_NOISY = ObjectiveRFun$new(fun = FUN_1D_NOISY, domain = PS_1D, codomain = FUN_1D_CODOMAIN, properties = c("single-crit", "noisy"))
24+
OBJ_1D_NOISY = bbotk::ObjectiveRFun$new(fun = FUN_1D_NOISY, domain = PS_1D, codomain = FUN_1D_CODOMAIN, properties = c("single-crit", "noisy"))
2525

2626
FUN_1D_2_NOISY = function(xs) {
2727
list(y1 = as.numeric(xs)^2 + rnorm(1, sd = 0.5), y2 = sqrt(abs(as.numeric(xs))) + rnorm(1, sd = 0.5))
2828
}
29-
OBJ_1D_2_NOISY = ObjectiveRFun$new(fun = FUN_1D_2, domain = PS_1D, codomain = FUN_1D_2_CODOMAIN, properties = c("multi-crit", "noisy"))
29+
OBJ_1D_2_NOISY = bbotk::ObjectiveRFun$new(fun = FUN_1D_2, domain = PS_1D, codomain = FUN_1D_2_CODOMAIN, properties = c("multi-crit", "noisy"))
3030

3131
# Mixed 1D Functions
3232
PS_1D_MIXED = ps(
@@ -44,16 +44,16 @@ FUN_1D_MIXED = function(xs) {
4444
}
4545
list(y = (xs$x1 - switch(xs$x2, "a" = 0, "b" = 1, "c" = 2)) %% xs$x3 + (if (xs$x4) xs$x1 else pi))
4646
}
47-
OBJ_1D_MIXED = ObjectiveRFun$new(fun = FUN_1D_MIXED, domain = PS_1D_MIXED, properties = "single-crit")
48-
OBJ_1D_MIXED_DEPS = ObjectiveRFun$new(fun = FUN_1D_MIXED, domain = PS_1D_MIXED_DEPS, properties = "single-crit")
47+
OBJ_1D_MIXED = bbotk::ObjectiveRFun$new(fun = FUN_1D_MIXED, domain = PS_1D_MIXED, properties = "single-crit")
48+
OBJ_1D_MIXED_DEPS = bbotk::ObjectiveRFun$new(fun = FUN_1D_MIXED, domain = PS_1D_MIXED_DEPS, properties = "single-crit")
4949

5050
FUN_1D_2_MIXED = function(xs) {
5151
if (is.null(xs$x2)) {
5252
xs$x2 = "a"
5353
}
5454
list(y1 = (xs$x1 - switch(xs$x2, "a" = 0, "b" = 1, "c" = 2)) %% xs$x3 + (if (xs$x4) xs$x1 else pi), y2 = xs$x1)
5555
}
56-
OBJ_1D_2_MIXED = ObjectiveRFun$new(fun = FUN_1D_2_MIXED, domain = PS_1D_MIXED, codomain = FUN_1D_2_CODOMAIN, properties = "multi-crit")
56+
OBJ_1D_2_MIXED = bbotk::ObjectiveRFun$new(fun = FUN_1D_2_MIXED, domain = PS_1D_MIXED, codomain = FUN_1D_2_CODOMAIN, properties = "multi-crit")
5757

5858
# Simple 2D Functions
5959
PS_2D = ps(
@@ -69,14 +69,14 @@ FUN_2D = function(xs) {
6969
list(y = y)
7070
}
7171
FUN_2D_CODOMAIN = ps(y = p_dbl(tags = c("minimize", "random_tag")))
72-
OBJ_2D = ObjectiveRFun$new(fun = FUN_2D, domain = PS_2D, properties = "single-crit")
72+
OBJ_2D = bbotk::ObjectiveRFun$new(fun = FUN_2D, domain = PS_2D, properties = "single-crit")
7373

7474
# Simple 2D Function with noise
7575
FUN_2D_NOISY = function(xs) {
7676
y = sum(as.numeric(xs)^2) + rnorm(1, sd = 0.5)
7777
list(y = y)
7878
}
79-
OBJ_2D_NOISY = ObjectiveRFun$new(fun = FUN_2D_NOISY, domain = PS_2D, properties = c("single-crit", "noisy"))
79+
OBJ_2D_NOISY = bbotk::ObjectiveRFun$new(fun = FUN_2D_NOISY, domain = PS_2D, properties = c("single-crit", "noisy"))
8080

8181
# Instance helper
8282
MAKE_INST = function(objective = OBJ_2D, search_space = PS_2D, terminator = trm("evals", n_evals = 10L)) {
@@ -109,7 +109,7 @@ if (requireNamespace("mlr3learners") && requireNamespace("DiceKriging") && requi
109109
REGR_FEATURELESS = lrn("regr.featureless")
110110
REGR_FEATURELESS$encapsulate("callr", lrn("regr.featureless"))
111111

112-
OptimizerError = R6Class("OptimizerError",
112+
OptimizerError = R6::R6Class("OptimizerError",
113113
inherit = OptimizerBatch,
114114
public = list(
115115

@@ -129,7 +129,7 @@ OptimizerError = R6Class("OptimizerError",
129129
)
130130
)
131131

132-
LearnerRegrError = R6Class("LearnerRegrError",
132+
LearnerRegrError = R6::R6Class("LearnerRegrError",
133133
inherit = LearnerRegr,
134134
public = list(
135135

0 commit comments

Comments
 (0)