[SciPy-user] Correct syntax for optimize.fmin_powell

Robert Kern rkern at ucsd.edu
Mon Sep 12 23:48:43 CDT 2005


Dan Christensen wrote:
> Robert Kern <rkern at ucsd.edu> writes:
> 
> 
>>J. Stark wrote:
>>
>>
>>>I am typically trying to something like
>>>
>>>def test_arg((x,y),(a,b)):
>>>    return (x-a)**2 + (y-b)**2
>>>
>>>min = optimize.fmin_powell(test_arg,(1.0,2.0), ((5.0,6.0),))
>>>
>>>This works with optimize.fmin, but fails with optimize.fmin_powell.
>>
>>Works for me.
>>
>>In [2]: def test_arg((x,y),(a,b)):
>>   ...:     return (x-a)**2 + (y-b)**2
>>   ...:
>>
>>In [3]: min = optimize.fmin_powell(test_arg,(1.0,2.0), ((5.0,6.0),))
> 
> 
> Doesn't work for me.  Debian, python 2.4.1, Debian's scipy packages:

[snip]

> TypeError: test_arg() takes exactly 2 arguments (3 given)

Could you also copy-and-paste the code that you ran to yield this error?
Because it looks to me like you may have executed

  min = optimize.fmin_powell(test_arg,(1.0,2.0), (5.0,6.0))

instead.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter



More information about the SciPy-user mailing list