ODE.jl
ODE.jl copied to clipboard
Suggestion: return status of integration as part of tuple / values.
I would like to be able to get the status when I need to check on it, rather than as a println or an exception. Status like "success", "break: minimum step size", "outside of domain", etc.
This would make it easier to handle or ignore different statuses.
If this status was somehow optionally accessible, that would be perfect.
I would also be willing to help out with coding this, if needed.
+1 It would also be great if the solvers would return the integration up to the point where an error was thrown.
If we stop throwing errors for failed integrations, this is a severely breaking change for users who rely on errors to inform them that the integration wasn't successful. To have the code just silently return an integrated result that isn't complete and not notice that something wen't wrong unless you remember to check the status flag seems like an API regression to difficult-to-use C libraries. Not something I'd vote for.
We could, however, add a few exception types that signal what went wrong, and carry any interesting data, and throw them instead of generic ones. For example, consider
immutable StepSizeError <: Exception
step_size_at_end
tout_so_far
yout_so_far
end
# and in the solver
if step < threshold
throw(StepSizeError(step, tout, yout))
end
Now, the caller can wrap the solver in try ... catch, and handle some or all possible faults at will, without breaking the API for users who rely on errors to signal that tout, yout should not be entirely trusted.
Yeah I can see what you are saying, better exceptions / errors would probably be the way to go.
This would still let me handle errors as they appear and let me decide if I want to use the integration up to the point or not.
I'm all for not breaking anyone else's code. :)