Learner1D.ask breaks when adding points in some order
l = adaptive.Learner1D(lambda x: x, (0, 1))
l.tell_many([1, 0, 0.5], [0, 0, 0])
l.ask(1)
Traceback
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-17-1b520d635f37> in <module>()
2 l = adaptive.Learner1D(lambda x: x, (0, 1))
3 l.tell_many([1, 0, 0.5], [0, 0, 0])
----> 4 l.ask(1)
~/Work/adaptive/adaptive/learner/learner1D.py in ask(self, n, add_data)
301 in self.neighbors.items()][:-1]
302
--> 303 for x_left, x_right in intervals:
304 self.losses[x_left, x_right] = (
305 self.loss_per_interval((x_left, x_right), self._scale, self.data)
~/Work/adaptive/adaptive/learner/base_learner.py in tell_many(self, xs, ys)
43 """
44 for x, y in zip(xs, ys):
---> 45 self.tell(x, y)
46
47 @abc.abstractmethod
~/Work/adaptive/adaptive/learner/learner1D.py in tell(self, x, y)
239 self.update_scale(x, y)
240
--> 241 # Update the losses
242 self.update_losses(x, real)
243
~/Work/adaptive/adaptive/learner/learner1D.py in update_losses(self, x, real)
159 a, b = self.find_neighbors(x, self.neighbors_combined)
160 if x_left is not None and x_right is not None:
--> 161 dx = x_right - x_left
162 loss = self.losses[x_left, x_right]
163 losses_combined[a, x] = (x - a) * loss / dx
KeyError: (0, 1)