We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c26ac92 commit a49142cCopy full SHA for a49142c
1 file changed
adaptive/tests/test_balancing_learner.py
@@ -0,0 +1,23 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from ..learner import Learner1D, BalancingLearner
4
5
6
+def test_balancing_learner_loss_cache():
7
+ learner = Learner1D(lambda x: x, bounds=(-1, 1))
8
+ learner.tell(-1, -1)
9
+ learner.tell(1, 1)
10
+ learner.tell_pending(0)
11
12
+ real_loss = learner.loss(real=True)
13
+ pending_loss = learner.loss(real=False)
14
15
+ # Test if the real and pending loss are cached correctly
16
+ bl = BalancingLearner([learner])
17
+ assert bl.loss(real=True) == real_loss
18
+ assert bl.loss(real=False) == pending_loss
19
20
+ # Test if everything is still fine when executed in the reverse order
21
22
23
0 commit comments