Skip to content

Commit 7eea192

Browse files
committed
Allow x0 and bound inputs to be lists (internally convert to numpy.ndarray)
1 parent d14d64c commit 7eea192

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pybobyqa/solver.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ def solve_main(objfun, x0, args, xl, xu, npt, rhobeg, rhoend, maxfun, nruns_so_f
640640
def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8, maxfun=None, nsamples=None, user_params=None,
641641
objfun_has_noise=False, seek_global_minimum=False, scaling_within_bounds=False):
642642
n = len(x0)
643+
if type(x0) == list:
644+
x0 = np.array(x0, dtype=np.float)
643645

644646
# Set missing inputs (if not specified) to some sensible defaults
645647
if bounds is None:
@@ -649,7 +651,11 @@ def solve(objfun, x0, args=(), bounds=None, npt=None, rhobeg=None, rhoend=1e-8,
649651
else:
650652
assert len(bounds) == 2, "bounds must be a 2-tuple of (lower, upper), where both are arrays of size(x0)"
651653
xl = bounds[0]
654+
if type(xl) == list:
655+
xl = np.array(xl, dtype=np.float)
652656
xu = bounds[1]
657+
if type(xu) == list:
658+
xu = np.array(xu, dtype=np.float)
653659

654660
exit_info = None
655661
if seek_global_minimum and (xl is None or xu is None):

0 commit comments

Comments
 (0)