Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
basnijholt opened this issue Dec 19, 2018 · 1 comment
Closed

Comments

@basnijholt
Copy link
Member

(original issue on GitLab)

opened by Bas Nijholt (@basnijholt) at 2018-09-13T14:18:58.918Z

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'
@basnijholt
Copy link
Member Author

originally posted by Jorn Hoofwijk (@Jorn) at 2018-09-15T11:44:24.068Z on GitLab

I suppose we convert the list to a np.array, maybe even typed (so set dtype=float64)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant