Skip to content

Commit 21a8ef9

Browse files
committed
implement BalancingLearner.nsamples to fix test_saving_of_balancing_learner
1 parent 4a363a2 commit 21a8ef9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

adaptive/learner/balancing_learner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ def pending_points(self):
106106
def npoints(self):
107107
return sum(l.npoints for l in self.learners)
108108

109+
@property
110+
def nsamples(self):
111+
if hasattr(self.learners[0], "nsamples"):
112+
return sum(l.nsamples for l in self.learners)
113+
else:
114+
raise AttributeError(
115+
f"{type(self.learners[0])} as no attribute called `nsamples`."
116+
)
117+
109118
@property
110119
def strategy(self):
111120
"""Can be either 'loss_improvements' (default), 'loss', 'npoints', or

0 commit comments

Comments
 (0)