Skip to content

Commit 396fa52

Browse files
committed
BalancingLearner: test the "cycle" strategy
1 parent 221a5b3 commit 396fa52

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adaptive/tests/test_balancing_learner.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from adaptive.runner import simple
77

88

9+
strategies = ['loss', 'loss_improvements', 'npoints', 'cycle']
10+
11+
912
def 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)
3033
def 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)
4548
def test_ask_0(strategy):
4649
learners = [Learner1D(lambda x: x, bounds=(-1, 1)) for i in range(10)]
4750
learner = BalancingLearner(learners, strategy=strategy)
@@ -53,6 +56,7 @@ def test_ask_0(strategy):
5356
('loss', lambda l: l.loss() < 0.1),
5457
('loss_improvements', lambda l: l.loss() < 0.1),
5558
('npoints', lambda bl: all(l.npoints > 10 for l in bl.learners)),
59+
('cycle', lambda l: l.loss() < 0.1),
5660
])
5761
def test_strategies(strategy, goal):
5862
learners = [Learner1D(lambda x: x, bounds=(-1, 1)) for i in range(10)]

0 commit comments

Comments
 (0)