python - Specifying the ranges in scipy.optimize.brute() -


when try minimize function scipy.minimize.brute() using following code:

import scipy scipy.optimize.brute(lambda x: x**2, ranges=(-2,3)) 

i following error:

typeerror: object of type 'int' has no len() 

i suppose has specification of range, don't see why. documentation says

each component of ranges tuple must either “slice object” or range tuple of form (low, high).

where mistake?

as documentation says:

each component of ranges tuple must either “slice object” or range tuple of form (low, high).

so function expects tuple of tuples, 1 of form (low, high) each dimension. have 1 dimension, correct call in case be

scipy.optimize.brute(lambda x: x**2, ranges=((-2,3),) ) 

Comments

Popular posts from this blog

vue.js - Create hooks for automated testing -

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

serial port - hub4com OVERRUN Error -