See https://github.com/python-adaptive/adaptive/issues/159
Bas Nijholt authored on 16/03/2019 12:11:55... | ... |
@@ -161,11 +161,19 @@ class BalancingLearner(BaseLearner): |
161 | 161 |
|
162 | 162 |
def ask(self, n, tell_pending=True): |
163 | 163 |
"""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 |
+ |
|
164 | 172 |
if not tell_pending: |
165 | 173 |
with restore(*self.learners): |
166 |
- return self._ask_and_tell(n) |
|
174 |
+ return ask_and_tell(n) |
|
167 | 175 |
else: |
168 |
- return self._ask_and_tell(n) |
|
176 |
+ return ask_and_tell(n) |
|
169 | 177 |
|
170 | 178 |
def tell(self, x, y): |
171 | 179 |
index, x = x |