@@ -54,7 +54,7 @@ def test_to_numerical(evaluations, search_space, greater_is_better):
54
54
55
55
objective = Objective (objective_name , greater_is_better )
56
56
57
- X , Y = to_numerical (evaluations , search_space , objective )
57
+ X , Y = to_numerical (evaluations , search_space , [ objective ] )
58
58
59
59
assert X .dtype == torch .float32
60
60
assert Y .dtype == torch .float32
@@ -82,7 +82,7 @@ def test_to_numerical_with_batch(evaluations, search_space):
82
82
objective = Objective (objective_name , False )
83
83
84
84
batch_shape = torch .Size ((1 ,))
85
- X , Y = to_numerical (evaluations , search_space , objective , batch_shape = batch_shape )
85
+ X , Y = to_numerical (evaluations , search_space , [ objective ] , batch_shape = batch_shape )
86
86
87
87
assert X .dtype == torch .float32
88
88
assert Y .dtype == torch .float32
@@ -102,31 +102,31 @@ def test_to_numerical_raises_errors(search_space):
102
102
objectives = {objective_name : 0.64 },
103
103
)
104
104
with pytest .raises (ValueError , match = "Mismatch" ):
105
- to_numerical ([eval_err ], search_space , objective )
105
+ to_numerical ([eval_err ], search_space , [ objective ] )
106
106
107
107
# parameter not within defined bounds -> invalid configuration
108
108
eval_err = Evaluation (
109
109
configuration = {"x0" : 0.1 , "x1" : False , "x2" : "small" , "fp" : 0.5 },
110
110
objectives = {objective_name : 0.64 },
111
111
)
112
112
with pytest .raises (ValueError , match = "not valid" ):
113
- to_numerical ([eval_err ], search_space , objective )
113
+ to_numerical ([eval_err ], search_space , [ objective ] )
114
114
115
115
# conditional parameter should be active, but is inactive -> invalid configuration
116
116
eval_err = Evaluation (
117
117
configuration = {"x0" : 0.57 , "x1" : True , "x2" : "small" , "fp" : 0.5 },
118
118
objectives = {objective_name : 0.64 },
119
119
)
120
120
with pytest .raises (ValueError , match = "not valid" ):
121
- to_numerical ([eval_err ], search_space , objective )
121
+ to_numerical ([eval_err ], search_space , [ objective ] )
122
122
123
123
# conditional parameter should be inactive, but is active -> invalid configuration
124
124
eval_err = Evaluation (
125
125
configuration = {"x0" : 0.57 , "x1" : False , "x2" : "small" , "cp" : 0.3 , "fp" : 0.5 },
126
126
objectives = {objective_name : 0.64 },
127
127
)
128
128
with pytest .raises (ValueError , match = "not valid" ):
129
- to_numerical ([eval_err ], search_space , objective )
129
+ to_numerical ([eval_err ], search_space , [ objective ] )
130
130
131
131
132
132
@pytest .mark .parametrize (
@@ -147,7 +147,7 @@ def test_to_numerical_with_constraints(
147
147
_ , Y = to_numerical (
148
148
evaluations_with_constraints ,
149
149
search_space ,
150
- objective ,
150
+ [ objective ] ,
151
151
constraints ,
152
152
)
153
153
@@ -172,7 +172,7 @@ def test_to_numerical_raises_error_on_wrong_constraints(
172
172
to_numerical (
173
173
evaluations_with_constraints ,
174
174
search_space ,
175
- objective ,
175
+ [ objective ] ,
176
176
constraint_names = ["WRONG_NAME" ],
177
177
)
178
178
@@ -190,11 +190,32 @@ def test_to_numerical_raises_error_on_wrong_constraints(
190
190
to_numerical (
191
191
evaluations ,
192
192
search_space ,
193
- objective ,
193
+ [ objective ] ,
194
194
constraint_names = [constraint_name_1 ],
195
195
)
196
196
197
197
198
+ def test_to_numerical_multiple_objectives (search_space ):
199
+ objectives = [
200
+ Objective ("score" , greater_is_better = True ),
201
+ Objective ("loss" , greater_is_better = False ),
202
+ ]
203
+
204
+ evaluations = [
205
+ Evaluation (
206
+ objectives = {"score" : 0.1 , "loss" : 0.1 }, configuration = search_space .sample ()
207
+ )
208
+ ]
209
+
210
+ X , Y = to_numerical (evaluations , search_space , objectives )
211
+
212
+ assert X .dtype == torch .float32
213
+ assert Y .dtype == torch .float32
214
+ assert X .size () == (len (evaluations ), len (search_space ))
215
+ assert Y .size () == (len (evaluations ), len (objectives ))
216
+ assert torch .equal (Y , torch .Tensor ([[- 0.1 , 0.1 ]]))
217
+
218
+
198
219
def test_filter_y_nans ():
199
220
x1 = torch .tensor ([[0.1 ], [0.7 ], [1.0 ]])
200
221
y1 = torch .tensor ([[0.8 ], [0.3 ], [0.5 ]])
0 commit comments