Skip to content

Commit 4646cdf

Browse files
authored
fix: import error from exception module (#525)
1 parent 10ef3be commit 4646cdf

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/test_acquisition.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from scipy.spatial.distance import pdist
88
from sklearn.gaussian_process import GaussianProcessRegressor
99

10-
from bayes_opt import acquisition
10+
from bayes_opt import acquisition, exception
1111
from bayes_opt.constraint import ConstraintModel
1212
from bayes_opt.target_space import TargetSpace
1313

@@ -94,7 +94,7 @@ def test_upper_confidence_bound(gp, target_space, random_state):
9494

9595
# Test that the suggest method raises an error if the GP is unfitted
9696
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"
9898
):
9999
acq.suggest(gp=gp, target_space=target_space)
100100

@@ -122,7 +122,7 @@ def test_upper_confidence_bound_with_constraints(gp, constrained_target_space, r
122122
acq = acquisition.UpperConfidenceBound(random_state=random_state)
123123

124124
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):
126126
acq.suggest(gp=gp, target_space=constrained_target_space)
127127

128128

@@ -157,11 +157,11 @@ def test_probability_of_improvement_with_constraints(gp, constrained_target_spac
157157
with pytest.raises(ValueError, match="y_max is not set"):
158158
acq.base_acq(0.0, 0.0)
159159

160-
with pytest.raises(acquisition.TargetSpaceEmptyError):
160+
with pytest.raises(exception.TargetSpaceEmptyError):
161161
acq.suggest(gp=gp, target_space=constrained_target_space)
162162

163163
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):
165165
acq.suggest(gp=gp, target_space=constrained_target_space)
166166

167167
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
199199
with pytest.raises(ValueError, match="y_max is not set"):
200200
acq.base_acq(0.0, 0.0)
201201

202-
with pytest.raises(acquisition.TargetSpaceEmptyError):
202+
with pytest.raises(exception.TargetSpaceEmptyError):
203203
acq.suggest(gp=gp, target_space=constrained_target_space)
204204

205205
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):
207207
acq.suggest(gp=gp, target_space=constrained_target_space)
208208

209209
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
250250
base_acq = acquisition.UpperConfidenceBound(random_state=random_state)
251251
acq = acquisition.ConstantLiar(base_acquisition=base_acq, random_state=random_state)
252252

253-
with pytest.raises(acquisition.TargetSpaceEmptyError):
253+
with pytest.raises(exception.TargetSpaceEmptyError):
254254
acq.suggest(gp=gp, target_space=constrained_target_space)
255255

256256
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):
258258
acq.suggest(gp=gp, target_space=constrained_target_space)
259259

260260
mean = random_state.rand(10)
@@ -338,7 +338,7 @@ def test_gphedge_integration(gp, target_space, random_state):
338338

339339
acq = acquisition.GPHedge(base_acquisitions=base_acquisitions, random_state=random_state)
340340
assert acq.base_acquisitions == base_acquisitions
341-
with pytest.raises(acquisition.TargetSpaceEmptyError):
341+
with pytest.raises(exception.TargetSpaceEmptyError):
342342
acq.suggest(gp=gp, target_space=target_space)
343343
target_space.register(params={"x": 2.5, "y": 0.5}, target=3.0)
344344

0 commit comments

Comments
 (0)