1
+ from typing import Callable
2
+
1
3
import pytest
2
4
3
5
from adaptive .learner import BalancingLearner , Learner1D
6
8
strategies = ["loss" , "loss_improvements" , "npoints" , "cycle" ]
7
9
8
10
9
- def test_balancing_learner_loss_cache ():
11
+ def test_balancing_learner_loss_cache () -> None :
10
12
learner = Learner1D (lambda x : x , bounds = (- 1 , 1 ))
11
13
learner .tell (- 1 , - 1 )
12
14
learner .tell (1 , 1 )
@@ -27,7 +29,7 @@ def test_balancing_learner_loss_cache():
27
29
28
30
29
31
@pytest .mark .parametrize ("strategy" , strategies )
30
- def test_distribute_first_points_over_learners (strategy ) :
32
+ def test_distribute_first_points_over_learners (strategy : str ) -> None :
31
33
for initial_points in [0 , 3 ]:
32
34
learners = [Learner1D (lambda x : x , bounds = (- 1 , 1 )) for i in range (10 )]
33
35
learner = BalancingLearner (learners , strategy = strategy )
@@ -42,7 +44,7 @@ def test_distribute_first_points_over_learners(strategy):
42
44
43
45
44
46
@pytest .mark .parametrize ("strategy" , strategies )
45
- def test_ask_0 (strategy ) :
47
+ def test_ask_0 (strategy : str ) -> None :
46
48
learners = [Learner1D (lambda x : x , bounds = (- 1 , 1 )) for i in range (10 )]
47
49
learner = BalancingLearner (learners , strategy = strategy )
48
50
points , _ = learner .ask (0 )
@@ -58,7 +60,7 @@ def test_ask_0(strategy):
58
60
("cycle" , lambda l : l .loss () < 0.1 ),
59
61
],
60
62
)
61
- def test_strategies (strategy , goal ) :
63
+ def test_strategies (strategy : str , goal : Callable ) -> None :
62
64
learners = [Learner1D (lambda x : x , bounds = (- 1 , 1 )) for i in range (10 )]
63
65
learner = BalancingLearner (learners , strategy = strategy )
64
66
simple (learner , goal = goal )
0 commit comments