6
6
from adaptive .runner import simple
7
7
8
8
9
+ strategies = ["loss" , "loss_improvements" , "npoints" , "cycle" ]
10
+
11
+
9
12
def test_balancing_learner_loss_cache ():
10
13
learner = Learner1D (lambda x : x , bounds = (- 1 , 1 ))
11
14
learner .tell (- 1 , - 1 )
@@ -26,7 +29,7 @@ def test_balancing_learner_loss_cache():
26
29
assert bl .loss (real = True ) == real_loss
27
30
28
31
29
- @pytest .mark .parametrize ("strategy" , [ "loss" , "loss_improvements" , "npoints" ] )
32
+ @pytest .mark .parametrize ("strategy" , strategies )
30
33
def test_distribute_first_points_over_learners (strategy ):
31
34
for initial_points in [0 , 3 ]:
32
35
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):
41
44
assert len (set (i_learner )) == len (learners )
42
45
43
46
44
- @pytest .mark .parametrize ("strategy" , [ "loss" , "loss_improvements" , "npoints" ] )
47
+ @pytest .mark .parametrize ("strategy" , strategies )
45
48
def test_ask_0 (strategy ):
46
49
learners = [Learner1D (lambda x : x , bounds = (- 1 , 1 )) for i in range (10 )]
47
50
learner = BalancingLearner (learners , strategy = strategy )
@@ -55,6 +58,7 @@ def test_ask_0(strategy):
55
58
("loss" , lambda l : l .loss () < 0.1 ),
56
59
("loss_improvements" , lambda l : l .loss () < 0.1 ),
57
60
("npoints" , lambda bl : all (l .npoints > 10 for l in bl .learners )),
61
+ ("cycle" , lambda l : l .loss () < 0.1 ),
58
62
],
59
63
)
60
64
def test_strategies (strategy , goal ):
0 commit comments