Skip to content

Commit e6afb71

Browse files
committed
BalancingLearner: test the "cycle" strategy
1 parent 9f249cf commit e6afb71

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)
@@ -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
)
6064
def test_strategies(strategy, goal):

0 commit comments

Comments
 (0)