File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22
33from adaptive .learner import Learner1D , BalancingLearner
4-
4+ from adaptive . runner import simple
55
66def 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 )
You can’t perform that action at this time.
0 commit comments