Skip to content

Commit d57677e

Browse files
committed
add type annotations for adaptive/tests/test_balancing_learner.py
1 parent 92b2547 commit d57677e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

adaptive/tests/test_balancing_learner.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Callable
2+
13
import pytest
24

35
from adaptive.learner import BalancingLearner, Learner1D
@@ -6,7 +8,7 @@
68
strategies = ["loss", "loss_improvements", "npoints", "cycle"]
79

810

9-
def test_balancing_learner_loss_cache():
11+
def test_balancing_learner_loss_cache() -> None:
1012
learner = Learner1D(lambda x: x, bounds=(-1, 1))
1113
learner.tell(-1, -1)
1214
learner.tell(1, 1)
@@ -27,7 +29,7 @@ def test_balancing_learner_loss_cache():
2729

2830

2931
@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:
3133
for initial_points in [0, 3]:
3234
learners = [Learner1D(lambda x: x, bounds=(-1, 1)) for i in range(10)]
3335
learner = BalancingLearner(learners, strategy=strategy)
@@ -42,7 +44,7 @@ def test_distribute_first_points_over_learners(strategy):
4244

4345

4446
@pytest.mark.parametrize("strategy", strategies)
45-
def test_ask_0(strategy):
47+
def test_ask_0(strategy: str) -> None:
4648
learners = [Learner1D(lambda x: x, bounds=(-1, 1)) for i in range(10)]
4749
learner = BalancingLearner(learners, strategy=strategy)
4850
points, _ = learner.ask(0)
@@ -58,7 +60,7 @@ def test_ask_0(strategy):
5860
("cycle", lambda l: l.loss() < 0.1),
5961
],
6062
)
61-
def test_strategies(strategy, goal):
63+
def test_strategies(strategy: str, goal: Callable) -> None:
6264
learners = [Learner1D(lambda x: x, bounds=(-1, 1)) for i in range(10)]
6365
learner = BalancingLearner(learners, strategy=strategy)
6466
simple(learner, goal=goal)

0 commit comments

Comments
 (0)