-
Notifications
You must be signed in to change notification settings - Fork 46
feat: use warning and not exception to indicate no convergence #286
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
base: dev
Are you sure you want to change the base?
Conversation
talledodiego
left a comment
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.
The idea seems solid to me.
I tested it in a jupyter notebook and it seems to show correctly warnings each time.
We can probably extend this to other algorithms where we raise an exception for reaching the maximum number of iterations.
Would you like to explore the idea in other algorithms? You have more insight in the other methods on the |
Sure! I will work on this same PR. Hopefully during tonight's session |
|
@mortenengen finished here from my side. Up for your review. |
This is an experiment to use warnings instead of exceptions to indicate that an iterative solution does not reach convergence.
When no convergence is reached, it can be useful to return some calculation results to the user, so that these results can be examined, and measures can be implemented.
In the current implementation, no convergence is indicated by raising an exception, and therefore, no results are returned from the iterative solver. In this PR, a custom warning is shown instead, and the results at the time of the warning was shown are returned to the user.
To make sure that the warning is always shown, a custom filter is added. The user can always override this behavior, e.g. only showing it once, completely ignoring it, or even raising it as an error.