Labels

Thursday, August 27, 2020

Scipy optimize error "length of x0 != length of bounds"

 

from scipy.optimize import minimize
def fun(x):
    return x-1
minimize(fun, [2],bounds = ((0,4)))
It will raise "ValueError: length of x0 != length of bounds". We should change ((0,4)) to ((0,4),)
minimize(fun, [2], bounds=((0, 4),))
Reference: https://github.com/scipy/scipy/issues/9692#issuecomment-455258618

No comments:

Post a Comment