@@ -43,7 +43,7 @@ def target_func():
4343
4444@pytest .fixture
4545def random_state ():
46- return np .random .RandomState ()
46+ return np .random .RandomState (0 )
4747
4848
4949@pytest .fixture
@@ -99,13 +99,20 @@ def test_acquisition_optimization(gp, target_space):
9999 acq .suggest (gp = gp , target_space = target_space , n_random = 0 , n_smart = 0 )
100100
101101
102- def test_acquisition_optimization_only_random (gp , target_space ):
102+ def test_acquisition_optimization_only_random (gp , target_space , random_state ):
103103 acq = MockAcquisition ()
104104 target_space .register (params = {"x" : 2.5 , "y" : 0.5 }, target = 3.0 )
105- res = acq .suggest (gp = gp , target_space = target_space , n_smart = 0 , n_random = 10_000 )
105+ res = acq .suggest (gp = gp , target_space = target_space , n_smart = 0 , n_random = 10_000 , random_state = random_state )
106106 # very lenient comparison as we're just considering random samples
107107 assert np .array ([3.0 , 1.0 ]) == pytest .approx (res , abs = 1e-1 , rel = 1e-1 )
108108
109+ # make sure that the best random sample is in the seeds
110+ acq_f = acq ._get_acq (gp = gp , constraint = target_space .constraint )
111+ x_min , _ , x_seeds = acq ._random_sample_minimize (
112+ acq_f , target_space , random_state = random_state , n_random = 10_000 , n_x_seeds = 3
113+ )
114+ assert x_min in x_seeds
115+
109116
110117def test_acquisition_optimization_only_l_bfgs_b (gp , target_space ):
111118 acq = MockAcquisition ()
0 commit comments