@@ -99,8 +99,9 @@ def test_register():
9999
100100
101101def test_register_with_constraint ():
102- constraint = ConstraintModel (lambda x : x , - 2 , 2 , transform = lambda x : x )
103- space = TargetSpace (target_func , PBOUNDS , constraint = constraint )
102+ constraint = ConstraintModel (lambda x : x , - 2 , 2 , transform = None )
103+ space = TargetSpace (target_func , PBOUNDS )
104+ space .set_constraint (constraint )
104105
105106 assert len (space ) == 0
106107 # registering with dict
@@ -195,7 +196,8 @@ def test_y_max():
195196def test_y_max_with_constraint ():
196197 PBOUNDS = {"p1" : (0 , 10 ), "p2" : (1 , 100 )}
197198 constraint = ConstraintModel (lambda p1 , p2 : p1 - p2 , - 2 , 2 )
198- space = TargetSpace (target_func , PBOUNDS , constraint )
199+ space = TargetSpace (target_func , PBOUNDS )
200+ space .set_constraint (constraint )
199201 assert space ._target_max () is None
200202 space .probe (params = {"p1" : 1 , "p2" : 2 }) # Feasible
201203 space .probe (params = {"p1" : 5 , "p2" : 1 }) # Unfeasible
@@ -229,7 +231,8 @@ def test_max():
229231def test_max_with_constraint ():
230232 PBOUNDS = {"p1" : (0 , 10 ), "p2" : (1 , 100 )}
231233 constraint = ConstraintModel (lambda p1 , p2 : p1 - p2 , - 2 , 2 )
232- space = TargetSpace (target_func , PBOUNDS , constraint = constraint )
234+ space = TargetSpace (target_func , PBOUNDS )
235+ space .set_constraint (constraint )
233236
234237 assert space .max () is None
235238 space .probe (params = {"p1" : 1 , "p2" : 2 }) # Feasible
@@ -242,7 +245,8 @@ def test_max_with_constraint():
242245def test_max_with_constraint_identical_target_value ():
243246 PBOUNDS = {"p1" : (0 , 10 ), "p2" : (1 , 100 )}
244247 constraint = ConstraintModel (lambda p1 , p2 : p1 - p2 , - 2 , 2 )
245- space = TargetSpace (target_func , PBOUNDS , constraint = constraint )
248+ space = TargetSpace (target_func , PBOUNDS )
249+ space .set_constraint (constraint )
246250
247251 assert space .max () is None
248252 space .probe (params = {"p1" : 1 , "p2" : 2 }) # Feasible
0 commit comments