Skip to content

Commit a46c335

Browse files
authored
Merge branch 'master' into constrained-optimization
2 parents 1a49eb1 + cc05408 commit a46c335

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
@@ -75,7 +75,7 @@ def to_minimize(x):
7575
for x_try in x_seeds:
7676
# Find the minimum of minus the acquisition function
7777
res = minimize(lambda x: to_minimize(x),
78-
x_try.reshape(1, -1),
78+
x_try,
7979
bounds=bounds,
8080
method="L-BFGS-B")
8181

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)