Skip to content

Learner1D fails when function returns a list instead of a numpy.array

def f(x):
    return [x, -x]

learner = adaptive.Learner1D(f, bounds=(-1, 1))
adaptive.runner.simple(learner, goal=lambda l: l.npoints > 200)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-e4aced43ce7b> in <module>()
      3 
      4 learner = adaptive.Learner1D(f, bounds=(-1, 1))
----> 5 adaptive.runner.simple(learner, goal=lambda l: l.npoints > 200)

~/Sync/Work/adaptive/adaptive/runner.py in simple(learner, goal)
    458         for x in xs:
    459             y = learner.function(x)
--> 460             learner.tell(x, y)
    461 
    462 

~/Sync/Work/adaptive/adaptive/learner/learner1D.py in tell(self, x, y)
    237 
    238         # Update the scale
--> 239         self.update_scale(x, y)
    240 
    241         # Update the losses

~/Sync/Work/adaptive/adaptive/learner/learner1D.py in update_scale(self, x, y)
    207                     y_min = y_max = y
    208                 self._bbox[1] = [y_min, y_max]
--> 209                 self._scale[1] = np.max(y_max - y_min)
    210             else:
    211                 self._bbox[1][0] = min(self._bbox[1][0], y)

TypeError: unsupported operand type(s) for -: 'list' and 'list'