File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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+
302323if __name__ == '__main__' :
303324 r"""
304325 CommandLine:
You can’t perform that action at this time.
0 commit comments