66from adaptive .runner import simple
77
88
9+ strategies = ["loss" , "loss_improvements" , "npoints" , "cycle" ]
10+
11+
912def test_balancing_learner_loss_cache ():
1013 learner = Learner1D (lambda x : x , bounds = (- 1 , 1 ))
1114 learner .tell (- 1 , - 1 )
@@ -26,7 +29,7 @@ def test_balancing_learner_loss_cache():
2629 assert bl .loss (real = True ) == real_loss
2730
2831
29- @pytest .mark .parametrize ("strategy" , [ "loss" , "loss_improvements" , "npoints" ] )
32+ @pytest .mark .parametrize ("strategy" , strategies )
3033def test_distribute_first_points_over_learners (strategy ):
3134 for initial_points in [0 , 3 ]:
3235 learners = [Learner1D (lambda x : x , bounds = (- 1 , 1 )) for i in range (10 )]
@@ -41,7 +44,7 @@ def test_distribute_first_points_over_learners(strategy):
4144 assert len (set (i_learner )) == len (learners )
4245
4346
44- @pytest .mark .parametrize ("strategy" , [ "loss" , "loss_improvements" , "npoints" ] )
47+ @pytest .mark .parametrize ("strategy" , strategies )
4548def test_ask_0 (strategy ):
4649 learners = [Learner1D (lambda x : x , bounds = (- 1 , 1 )) for i in range (10 )]
4750 learner = BalancingLearner (learners , strategy = strategy )
@@ -55,6 +58,7 @@ def test_ask_0(strategy):
5558 ("loss" , lambda l : l .loss () < 0.1 ),
5659 ("loss_improvements" , lambda l : l .loss () < 0.1 ),
5760 ("npoints" , lambda bl : all (l .npoints > 10 for l in bl .learners )),
61+ ("cycle" , lambda l : l .loss () < 0.1 ),
5862 ],
5963)
6064def test_strategies (strategy , goal ):
0 commit comments