Skip to content

Commit

Permalink
Cache the loss of a SequenceLearner (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Apr 16, 2023
1 parent 295516b commit 541e1f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion adaptive/learner/sequence_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from sortedcontainers import SortedDict, SortedSet

from adaptive.learner.base_learner import BaseLearner
from adaptive.utils import assign_defaults, partial_function_from_dataframe
from adaptive.utils import (
assign_defaults,
cache_latest,
partial_function_from_dataframe,
)

try:
import pandas
Expand Down Expand Up @@ -113,6 +117,7 @@ def ask(

return points, loss_improvements

@cache_latest
def loss(self, real: bool = True) -> float:
if not (self._to_do_indices or self.pending_points):
return 0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# -- Project information -----------------------------------------------------

project = "adaptive"
copyright = "2018-2022, Adaptive Authors"
copyright = "2018-2023, Adaptive Authors"
author = "Adaptive Authors"

# The short X.Y version
Expand Down

0 comments on commit 541e1f2

Please sign in to comment.