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
DOC: indicate possibility that line_search returns some values that are None #4312
Conversation
How about raising an exception instead? |
Yes that would make more sense. This PR is just intended to document the current behavior. |
argriffing a écrit :
The thing is that changing the current behavior to raise an exception |
I can easily imagine users that ran into |
I guess I'd also prefer a (documented) warning to be raised after all. Also "something has gone wrong" is not very informative, just saying that the line search algorithm did not converge might be better. |
I have a bias against adding warnings because of the drawbacks of design by committee. But in this case it might make sense. The meaning of the warning would be "Your optimization has failed, but for backwards compatibility this is a warning instead of an exception, and some of the return values of the line search function will be None." but the warning text should be translated into something more bland. |
Added the warning and improved the explanation for |
Thanks @argriffing. Sorry for nitpicking again but, wouldn't a plain |
@dlax I used |
argriffing a écrit :
I'd say that UserWarning (base class for warnings generated by user |
@dlax Currently I think the scipy tests never raise uncaught |
|
IIRC, OptimizeWarning concerns user code, so it's appropriate for it to be a UserWarning. |
@dlax At least the first of the following couple of uses does not particularly seem to concern user code, except in the loose sense that all optimization concerns user code at some level. |
argriffing wrote:
So there's an inconsistency. Anyways, I still fail to see the real problem with using a RuntimeWarning. |
I agree that there is not a real problem with using a |
Since the non-convergence is usually due to the user specifying something incorrectly, a subclass of |
Changed from |
DOC: indicate possibility that line_search returns some values that are None
Merged, thanks @argriffing ! |
FWIW this PR causes test errors on unreleased numpy. I think this is because they set some kind of global flags to escalate warnings to errors for more stringent testing during development than in released versions. |
This indicates that there are now warnings raised by tests added here which should be filtered out. The common pattern for that is:
|
Partially addresses #4257.