BUG: callback defined both in options of scipy.optimize.minimize and in its signature
See original GitHub issueDescribe your issue.
The documentation of version 1.8.0 says that callback
is one possible option of the L-BFGS-B solver, but setting that option causes an error :
_minimize_lbfgsb() got multiple values for keyword argument 'callback'
Indeed, the documentation also states that callback
is an argument.
Reproducing Code Example
>>> import numpy as np
>>> from scipy.optimize import minimize
>>> def f(x):
... return x*x
...
>>> minimize(f, np.array([10]), method="L-BFGS-B", options={"callback": lambda xk: print(xk)})
Error message
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vvargas-calderon/miniconda3/envs/zapata/lib/python3.8/site-packages/scipy/optimize/_minimize.py", line 681, in minimize
res = _minimize_lbfgsb(fun, x0, args, jac, bounds,
TypeError: _minimize_lbfgsb() got multiple values for keyword argument 'callback'
SciPy/NumPy/Python version information
1.8.0 1.21.6 sys.version_info(major=3, minor=8, micro=12, releaselevel=‘final’, serial=0)
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
scipy.optimize.minimize — SciPy v1.9.3 Manual
For method-specific options, see show_options . callbackcallable, optional. Called after each iteration. For 'trust-constr' it is a callable with the signature:.
Read more >python - scipy.optimize.minimize raises "my_callback() takes 1 ...
So, I debugged it and found that it calls scipy which, in turn, raises the same error for the following simple code: from...
Read more >Performing Fits and Analyzing Outputs
The minimize function takes an objective function to be minimized, a dictionary ( Parameters ) containing the model parameters, and several optional arguments....
Read more >04 - Optimization - Jupyter Notebooks Gallery
The scipy.optimize package provides several commonly used optimization ... Also, ``callback`` can be used to specify a user defined stop criterion by ...
Read more >List of algorithms — pygmo 2.18.0 documentation
This class is a user defined algorithm (UDA) providing a wrapper around the ... Construction arguments are those options of scipy.optimize.minimize() that ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found
_minimize_cobyla
has the same issue. I fixed both in this PR.Thanks! Yes it should be. But please wait for a confirmation from @andyfaff.