Skip to content

Commit 98318e0

Browse files
committed
rename 'total_samples' -> 'nsamples', inline with 'npoints'
1 parent 24814f1 commit 98318e0

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

adaptive/learner/average_learner1D.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ def __init__(
9494
self.rescaled_error = decreasing_dict()
9595

9696
@property
97-
def total_samples(self):
97+
def nsamples(self):
9898
"""Returns the total number of samples"""
9999
return sum(self._number_samples.values())
100100

101101
@property
102102
def min_samples_per_point(self):
103+
if not self._number_samples:
104+
return 0
103105
return min(self._number_samples.values())
104106

105107
def ask(self, n, tell_pending=True):

adaptive/notebook_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _info_html(runner):
263263
info.append(("# of points", runner.learner.npoints))
264264

265265
with suppress(Exception):
266-
info.append(("# of samples", runner.learner.total_samples))
266+
info.append(("# of samples", runner.learner.nsamples))
267267

268268
with suppress(Exception):
269269
info.append(("latest loss", f'{runner.learner._cache["loss"]:.3f}'))

docs/source/tutorial/tutorial.AverageLearner1D.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ second condition ensures that we have at least 20 samples at each point):
6565

6666
.. jupyter-execute::
6767

68-
def goal(total_samples):
68+
def goal(nsamples):
6969
def _goal(learner):
70-
min_samples = min(learner._number_samples.values())
71-
return learner.total_samples >= total_samples and min_samples >= 20
70+
return learner.nsamples >= nsamples and learner.min_samples_per_point >= 20
7271
return _goal
7372

7473
runner = adaptive.Runner(learner, goal=goal(10_000))

example-notebook.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@
370370
"\n",
371371
"\n",
372372
"def goal(l):\n",
373-
" return l.total_samples >= 10_000 and l.min_samples_per_point >= 20\n",
373+
" return l.nsamples >= 10_000 and l.min_samples_per_point >= 20\n",
374374
"\n",
375375
"\n",
376376
"runner = adaptive.Runner(learner, goal=goal)\n",

0 commit comments

Comments
 (0)