-
Notifications
You must be signed in to change notification settings - Fork 506
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
Check if alpha is not None when restricting it to be at most 1 #199
Conversation
4203747
to
ae7fbfe
Compare
ot/optim.py
Outdated
@@ -69,7 +69,7 @@ def phi(alpha1): | |||
alpha, phi1 = scalar_search_armijo( | |||
phi, phi0, derphi0, c1=c1, alpha0=alpha0) | |||
|
|||
return min(1, alpha), fc[0], phi1 | |||
return min(1, alpha) if alpha is not None else 1, fc[0], phi1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you put the test in another line with a small comment about what is necessary?
It is a bit hard to follow in the return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I guess you have an example where the original function failed. Could you do a simple no regression test it test_optim.py to check that this problem never re-appears again? It feels as if this function always needs tuning ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @panpan2 could you please take into account my comment so that we can merge your PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rflamary any other changes needed to merge this?
Types of changes
scipy.optimize.linesearch.scalar_search_armijo can return alpha=None (function definition). In optim.py:line_search_armijo as part of a previous issue #184, we restrict the value of alpha to be at most 1 with min(1, alpha) but this throws an Exception when alpha is None. In this PR, we just check the value of
alpha
is notNone
when making the comparison with1
.Motivation and context / Related issue
Issue: #198
How has this been tested (if it applies)
Checklist