Skip to content

Commit eaa1911

Browse files
committed
test the different strategies
1 parent a00bf61 commit eaa1911

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

adaptive/tests/test_balancing_learner.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
from adaptive.learner import Learner1D, BalancingLearner
4-
4+
from adaptive.runner import simple
55

66
def test_balancing_learner_loss_cache():
77
learner = Learner1D(lambda x: x, bounds=(-1, 1))
@@ -30,3 +30,16 @@ def test_distribute_first_points_over_learners():
3030
i_learner, xs = zip(*points)
3131
# assert that are all learners in the suggested points
3232
assert len(set(i_learner)) == len(learners)
33+
34+
35+
def test_strategies():
36+
goals = {
37+
'loss': lambda l: l.loss() < 0.1,
38+
'loss_improvements': lambda l: l.loss() < 0.1,
39+
'npoints': lambda bl: all(l.npoints > 10 for l in bl.learners)
40+
}
41+
42+
for strategy, goal in goals.items():
43+
learners = [Learner1D(lambda x: x, bounds=(-1, 1)) for i in range(10)]
44+
learner = BalancingLearner(learners, strategy=strategy)
45+
simple(learner, goal=goal)

0 commit comments

Comments
 (0)