Reputation: 1196
I am currently using scipy.optimize.fmin()
function and I am experiencing a problem with it. When I look at the documentation it says:
Returns:
xopt : ndarray
Parameter that minimizes function.
fopt : float
Value of function at minimum: fopt = func(xopt).
iter : int
Number of iterations performed.
funcalls : int
Number of function calls made.
warnflag : int
1 : Maximum number of function evaluations made. 2 : Maximum number of iterations reached.
allvecs : list
Solution at each iteration.
But when I try this:
res, min = opt.fmin(optim, self._params, (param_optim, self._paramsIni, Qmes, critere_efficacite, self, codeBV, interval), maxiter=5)
I get this error:
ValueError: too many values to unpack (expected 2)
Anyone has an idea why? I mean is the documention wrong (I guess not) or am I doing something wrong? I am using scipy 0.19 and Python34
Thanks in advance.
Upvotes: 0
Views: 1364
Reputation: 710
To be slightly more exact: The function returns either a tuple of 6 values (
full_output : bool, optional Set to True if fopt and warnflag outputs are desired.
) or one (if it is left at False
which is the default). If you want to have only the second value of the full output, I recommend you set full_output=True
and pattern-match as suggested in the comments. Alternativly you can store the result in one tuple res = opt.fmin(<your arguments>)
and then access r=res[0] min=res[1]
.
Upvotes: 3