question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: callback defined both in options of scipy.optimize.minimize and in its signature

See original GitHub issue

Describe 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:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
AtsushiSakaicommented, Jun 4, 2022

I found _minimize_cobyla has the same issue. I fixed both in this PR.

1reaction
tupuicommented, May 6, 2022

Thanks! Yes it should be. But please wait for a confirmation from @andyfaff.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found