|
7 | 7 | from scipy.spatial.distance import pdist
|
8 | 8 | from sklearn.gaussian_process import GaussianProcessRegressor
|
9 | 9 |
|
10 |
| -from bayes_opt import acquisition |
| 10 | +from bayes_opt import acquisition, exception |
11 | 11 | from bayes_opt.constraint import ConstraintModel
|
12 | 12 | from bayes_opt.target_space import TargetSpace
|
13 | 13 |
|
@@ -94,7 +94,7 @@ def test_upper_confidence_bound(gp, target_space, random_state):
|
94 | 94 |
|
95 | 95 | # Test that the suggest method raises an error if the GP is unfitted
|
96 | 96 | with pytest.raises(
|
97 |
| - acquisition.TargetSpaceEmptyError, match="Cannot suggest a point without previous samples" |
| 97 | + exception.TargetSpaceEmptyError, match="Cannot suggest a point without previous samples" |
98 | 98 | ):
|
99 | 99 | acq.suggest(gp=gp, target_space=target_space)
|
100 | 100 |
|
@@ -122,7 +122,7 @@ def test_upper_confidence_bound_with_constraints(gp, constrained_target_space, r
|
122 | 122 | acq = acquisition.UpperConfidenceBound(random_state=random_state)
|
123 | 123 |
|
124 | 124 | constrained_target_space.register(params={"x": 2.5, "y": 0.5}, target=3.0, constraint_value=0.5)
|
125 |
| - with pytest.raises(acquisition.ConstraintNotSupportedError): |
| 125 | + with pytest.raises(exception.ConstraintNotSupportedError): |
126 | 126 | acq.suggest(gp=gp, target_space=constrained_target_space)
|
127 | 127 |
|
128 | 128 |
|
@@ -157,11 +157,11 @@ def test_probability_of_improvement_with_constraints(gp, constrained_target_spac
|
157 | 157 | with pytest.raises(ValueError, match="y_max is not set"):
|
158 | 158 | acq.base_acq(0.0, 0.0)
|
159 | 159 |
|
160 |
| - with pytest.raises(acquisition.TargetSpaceEmptyError): |
| 160 | + with pytest.raises(exception.TargetSpaceEmptyError): |
161 | 161 | acq.suggest(gp=gp, target_space=constrained_target_space)
|
162 | 162 |
|
163 | 163 | constrained_target_space.register(params={"x": 2.5, "y": 0.5}, target=3.0, constraint_value=3.0)
|
164 |
| - with pytest.raises(acquisition.NoValidPointRegisteredError): |
| 164 | + with pytest.raises(exception.NoValidPointRegisteredError): |
165 | 165 | acq.suggest(gp=gp, target_space=constrained_target_space)
|
166 | 166 |
|
167 | 167 | constrained_target_space.register(params={"x": 1.0, "y": 0.0}, target=1.0, constraint_value=1.0)
|
@@ -199,11 +199,11 @@ def test_expected_improvement_with_constraints(gp, constrained_target_space, ran
|
199 | 199 | with pytest.raises(ValueError, match="y_max is not set"):
|
200 | 200 | acq.base_acq(0.0, 0.0)
|
201 | 201 |
|
202 |
| - with pytest.raises(acquisition.TargetSpaceEmptyError): |
| 202 | + with pytest.raises(exception.TargetSpaceEmptyError): |
203 | 203 | acq.suggest(gp=gp, target_space=constrained_target_space)
|
204 | 204 |
|
205 | 205 | constrained_target_space.register(params={"x": 2.5, "y": 0.5}, target=3.0, constraint_value=3.0)
|
206 |
| - with pytest.raises(acquisition.NoValidPointRegisteredError): |
| 206 | + with pytest.raises(exception.NoValidPointRegisteredError): |
207 | 207 | acq.suggest(gp=gp, target_space=constrained_target_space)
|
208 | 208 |
|
209 | 209 | constrained_target_space.register(params={"x": 1.0, "y": 0.0}, target=1.0, constraint_value=1.0)
|
@@ -250,11 +250,11 @@ def test_constant_liar_with_constraints(gp, constrained_target_space, random_sta
|
250 | 250 | base_acq = acquisition.UpperConfidenceBound(random_state=random_state)
|
251 | 251 | acq = acquisition.ConstantLiar(base_acquisition=base_acq, random_state=random_state)
|
252 | 252 |
|
253 |
| - with pytest.raises(acquisition.TargetSpaceEmptyError): |
| 253 | + with pytest.raises(exception.TargetSpaceEmptyError): |
254 | 254 | acq.suggest(gp=gp, target_space=constrained_target_space)
|
255 | 255 |
|
256 | 256 | constrained_target_space.register(params={"x": 2.5, "y": 0.5}, target=3.0, constraint_value=0.5)
|
257 |
| - with pytest.raises(acquisition.ConstraintNotSupportedError): |
| 257 | + with pytest.raises(exception.ConstraintNotSupportedError): |
258 | 258 | acq.suggest(gp=gp, target_space=constrained_target_space)
|
259 | 259 |
|
260 | 260 | mean = random_state.rand(10)
|
@@ -338,7 +338,7 @@ def test_gphedge_integration(gp, target_space, random_state):
|
338 | 338 |
|
339 | 339 | acq = acquisition.GPHedge(base_acquisitions=base_acquisitions, random_state=random_state)
|
340 | 340 | assert acq.base_acquisitions == base_acquisitions
|
341 |
| - with pytest.raises(acquisition.TargetSpaceEmptyError): |
| 341 | + with pytest.raises(exception.TargetSpaceEmptyError): |
342 | 342 | acq.suggest(gp=gp, target_space=target_space)
|
343 | 343 | target_space.register(params={"x": 2.5, "y": 0.5}, target=3.0)
|
344 | 344 |
|
|
0 commit comments