Skip to content

Commit a273049

Browse files
committed
distribute the suggested points over learners when no data is available
See #159
1 parent 442de97 commit a273049

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

adaptive/learner/balancing_learner.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,19 @@ def _ask_and_tell_based_on_npoints(self, n):
161161

162162
def ask(self, n, tell_pending=True):
163163
"""Chose points for learners."""
164+
if any(l.npoints for l in self.learners):
165+
ask_and_tell = self._ask_and_tell
166+
else:
167+
# If there are no data points yet,
168+
# distribute the points over all learners.
169+
# See https://github.com/python-adaptive/adaptive/issues/159
170+
ask_and_tell = self._ask_and_tell_based_on_npoints
171+
164172
if not tell_pending:
165173
with restore(*self.learners):
166-
return self._ask_and_tell(n)
174+
return ask_and_tell(n)
167175
else:
168-
return self._ask_and_tell(n)
176+
return ask_and_tell(n)
169177

170178
def tell(self, x, y):
171179
index, x = x

0 commit comments

Comments
 (0)