Skip to content

Commit 52a7252

Browse files
committed
simplify test_average_learner.py::test_min_npoints further
1 parent 9805b07 commit 52a7252

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

adaptive/tests/test_average_learner.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ def test_avg_std_and_npoints():
5050

5151

5252
def test_min_npoints():
53-
def f(seed):
54-
if seed < 2: # first two numbers are similar
55-
return 0.1 + 1e-8 * random.random()
56-
return random.random()
57-
58-
learner = AverageLearner(f, atol=0.01, rtol=0.01, min_npoints=3)
59-
simple(learner, lambda l: l.loss() < 1)
60-
assert learner.npoints > 2
53+
def constant_function(seed):
54+
return 0.1
55+
56+
for min_npoints in [1, 2, 3]:
57+
learner = AverageLearner(
58+
constant_function, atol=0.01, rtol=0.01, min_npoints=min_npoints
59+
)
60+
simple(learner, lambda l: l.loss() < 1)
61+
assert learner.npoints >= max(2, min_npoints)

0 commit comments

Comments
 (0)