Skip to content

Learner1D fails when a point (x, None) is added when x already exists

l = adaptive.Learner1D(lambda x: x, (0, 4))

l.tell(0, 0)
l.tell(1, 0)
l.tell(2, 0)

l.tell(1, None)

Traceback

KeyError                                  Traceback (most recent call last)
<ipython-input-73-d3d3808f7af0> in <module>()
      5 l.tell(2, 0)
      6 
----> 7 l.tell(1, None)

/opt/conda/lib/python3.6/site-packages/adaptive/learner/learner1D.py in tell(self, x, y)
    239 
    240         # Update the losses
--> 241         self.update_losses(x, real)
    242 
    243         # If the scale has increased enough, recompute all losses.

/opt/conda/lib/python3.6/site-packages/adaptive/learner/learner1D.py in update_losses(self, x, real)
    159             if x_left is not None and x_right is not None:
    160                 dx = x_right - x_left
--> 161                 loss = self.losses[x_left, x_right]
    162                 losses_combined[a, x] = (x - a) * loss / dx
    163                 losses_combined[x, b] = (b - x) * loss / dx

KeyError: (0, 2)