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

mclaugb mclaughlinbryan at yahoo.com
Sun Jan 28 15:18:24 CST 2007

If passed as a tuple, the error of my previous post occurs.

"Value Error:  Setting an array element with a sequence"  The line of code 
tries to add a tuple to ndarrays.  Should something be modified?

"Robert Kern" <robert.kern at gmail.com> wrote in message 
news:45BD0A7E.4030601 at gmail.com...
> 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