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 )
@@ -53,6 +56,7 @@ def test_ask_0(strategy):
53
56
('loss' , lambda l : l .loss () < 0.1 ),
54
57
('loss_improvements' , lambda l : l .loss () < 0.1 ),
55
58
('npoints' , lambda bl : all (l .npoints > 10 for l in bl .learners )),
59
+ ('cycle' , lambda l : l .loss () < 0.1 ),
56
60
])
57
61
def test_strategies (strategy , goal ):
58
62
learners = [Learner1D (lambda x : x , bounds = (- 1 , 1 )) for i in range (10 )]
0 commit comments