numericalalgorithmsgroup / pybobyqa

Python-based Derivative-Free Optimization with Bound Constraints
https://numericalalgorithmsgroup.github.io/pybobyqa/
GNU General Public License v3.0
78 stars 18 forks source link

TypeError: only integer scalar arrays can be converted to a scalar index #5

Closed fkarger closed 5 years ago

fkarger commented 5 years ago

First of all thank you for the great work! I was happy to see BOBYQA for Python :)

When calling pybobyqa.solve() with x0 being a list I get File "...\pybobyqa\solver.py", line 750, in solve x0[idx] = xl[idx] + rhobeg TypeError: only integer scalar arrays can be converted to a scalar index

This could be solved by checking if x0 is a list and then converting it to an array by using x0 = numpy.array(x0) I think this could be more convenient for the user who is maybe used to call the scipy-optimizers in conjunction with a list.

lindonroberts commented 5 years ago

Thanks, this is a good idea - fixed in commit https://github.com/numericalalgorithmsgroup/pybobyqa/commit/7eea192048ab2aa6ad197c6026f837c5fb53a4ff

fkarger commented 5 years ago

Maybe numpy.asarray() is even more flexible though I am not sure.