Skip to content

scipy/minimize-unknown-option

Pack Severity Fix Versions
SciPy error none, edit by hand All versions

minimize warns and ignores an option that the chosen method does not know, so the setting has no effect. Use an option that the method takes, which show_options lists.

res = minimize(f, x0, method="L-BFGS-B", options={"disp": True, "maxiter": 200})
res = minimize(f, x0, method="L-BFGS-B", options={"maxiter": 200})

The rule reports a key in the options= dict of optimize.minimize that the chosen method= doesn't take but another method takes. Examples are disp and iprint for L-BFGS-B, maxiter for TNC and maxfun for BFGS. On SciPy 1.18.1, minimize warns OptimizeWarning and ignores such a key, and with 'trust-constr' it raises TypeError. xpd took the keys of each method from a run of minimize with each pair of method and key.

xpd has no automatic fix, so make the change by hand.

minimize with method=$METH does not know the option $K and warns OptimizeWarning and ignores it. Use an option this method takes, which scipy.optimize.show_options('minimize', $METH) lists.

See all rules in the SciPy pack.