Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: optimize: support undocumented option full_output for optimize.curve_fit. #15330

Merged
merged 4 commits into from Jan 2, 2022

Conversation

AtsushiSakai
Copy link
Member

Reference issue

Fix #6772

What does this implement/fix?

As reported in #6772, optimize.curve_fit has an undocumented option full_output here:

# Remove full_output from kwargs, otherwise we're passing it in twice.
return_full = kwargs.pop('full_output', False)

I think the reason why the option is undocumented is that this option works only when the method is lm, which means using optimize.leastsq.
When one of the other methods is used, it returns OptimizeResult, this is different from the expected full output:
if return_full:
return popt, pcov, infodict, errmsg, ier

This PR enables users to use the option full_output regardless of the used method by creating the expected full output from the OptimzeResult.
Unfortunately, some kinds of output are not included in the OptimizeResult.
So these are ignored, but the full output structure is unified for all methods, the full_output can be officially supported.

@AtsushiSakai AtsushiSakai added enhancement A new feature or improvement scipy.optimize labels Jan 1, 2022
Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AtsushiSakai! Some vey minor comments.

scipy/optimize/tests/test_minpack.py Outdated Show resolved Hide resolved
scipy/optimize/_minpack_py.py Outdated Show resolved Hide resolved
AtsushiSakai and others added 4 commits January 2, 2022 12:31
Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @AtsushiSakai

@tupui tupui added this to the 1.9.0 milestone Jan 2, 2022
@tupui tupui merged commit a0e129f into scipy:master Jan 2, 2022
@AtsushiSakai AtsushiSakai deleted the issue_6772 branch January 2, 2022 12:24
@tupui
Copy link
Member

tupui commented Jan 7, 2022

@AtsushiSakai can you add a release note in https://github.com/scipy/scipy/wiki/Release-note-entries-for-SciPy-1.9.0? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.optimize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scipy.optimize.curve_fit's undocumented return_full keyword doesn't work with bounded problems
2 participants