Skip to content

Commit 541e1f2

Browse files
authored
Cache the loss of a SequenceLearner (#411)
1 parent 295516b commit 541e1f2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

adaptive/learner/sequence_learner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
from sortedcontainers import SortedDict, SortedSet
99

1010
from adaptive.learner.base_learner import BaseLearner
11-
from adaptive.utils import assign_defaults, partial_function_from_dataframe
11+
from adaptive.utils import (
12+
assign_defaults,
13+
cache_latest,
14+
partial_function_from_dataframe,
15+
)
1216

1317
try:
1418
import pandas
@@ -113,6 +117,7 @@ def ask(
113117

114118
return points, loss_improvements
115119

120+
@cache_latest
116121
def loss(self, real: bool = True) -> float:
117122
if not (self._to_do_indices or self.pending_points):
118123
return 0.0

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# -- Project information -----------------------------------------------------
1818

1919
project = "adaptive"
20-
copyright = "2018-2022, Adaptive Authors"
20+
copyright = "2018-2023, Adaptive Authors"
2121
author = "Adaptive Authors"
2222

2323
# The short X.Y version

0 commit comments

Comments
 (0)