Skip to content

Commit cc05408

Browse files
authored
Merge pull request #351 from bwheelz36/fix_scipy_1.9
changed the way x_try is sent to minimize - fixes #350
2 parents 7e888d7 + cd7a2e1 commit cc05408

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

bayes_opt/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def acq_max(ac, gp, y_max, bounds, random_state, n_warmup=10000, n_iter=10):
5353
for x_try in x_seeds:
5454
# Find the minimum of minus the acquisition function
5555
res = minimize(lambda x: -ac(x.reshape(1, -1), gp=gp, y_max=y_max),
56-
x_try.reshape(1, -1),
56+
x_try,
5757
bounds=bounds,
5858
method="L-BFGS-B")
5959

tests/test_bayesian_optimization.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,27 @@ def test_define_wrong_transformer():
299299
bounds_transformer=3)
300300

301301

302+
def test_single_value_objective():
303+
"""
304+
As documented [here](https://github.com/scipy/scipy/issues/16898)
305+
scipy is changing the way they handle 1D objectives inside minimize.
306+
This is a simple test to make sure our tests fail if scipy updates this
307+
in future
308+
"""
309+
pbounds = {'x': (-10, 10)}
310+
311+
optimizer = BayesianOptimization(
312+
f=lambda x: x*3,
313+
pbounds=pbounds,
314+
verbose=2,
315+
random_state=1,
316+
)
317+
optimizer.maximize(
318+
init_points=2,
319+
n_iter=3,
320+
)
321+
322+
302323
if __name__ == '__main__':
303324
r"""
304325
CommandLine:

0 commit comments

Comments
 (0)