[SciPy-user] scipy.optimise.lbfgsb /bounded optimization help

Robert Kern robert.kern at gmail.com
Sun Jan 28 14:41:34 CST 2007


mclaugb wrote:
> Thanks, that got me a little further.  I am now getting this error from the 
> approx_fprime function in optimize.py :
>   File "C:\Python24\lib\site-packages\scipy\optimize\optimize.py", line 577, 
> in approx_fprime
>     grad[k] = (apply(f,(xk+ei,)+(args)) - f0)/epsilon
> ValueError: setting an array element with a sequence.
> 
> It appears that args is a tuple rather than type 'numpy.ndarray' like the 
> others in the list.  The list of args that i provided to lbfgsb was
> args =  numpy.array([GammaMeas.real, GammaMeas.imag, Freq, BeadPerm.real, 
> BeadPerm.imag, Inner, Outer])
> 
> I could edit the section of code in optimize.py which is causing the error 
> at the grad[k] line but not sure that is the correct thing to do.

No, you should pass in args as a tuple rather than a list or an array.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco


More information about the SciPy-user mailing list