-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix BMI.update_until
(InexactError: Int64
)
#387
Conversation
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.
Choosing round here means that you can either undershoot or overshoot if the desired time does not fall on a model timestep. I feel like either an error or a cld
, where there can never be undershoot, may be a better option, though I'm not sure what the BMI best practices are for this.
Thanks for your comment @visr, good point. I think an improved error message may indeed be a better option than rounding. Will convert this PR back to draft, as it is not yet clear where the deviation from a whole number for the |
Perhaps it is almost exactly and integer, but not quite since it comes from floating point math. julia> t = 10 * (0.1 + 0.2)
3.0000000000000004
julia> Int(t)
ERROR: InexactError: Int64(3.0000000000000004)
julia> round(t)
3.0
julia> isapprox(round(t), t)
true That should probably be allowed at least, and a better error message for the not so close times would also be an improvement. |
Yes, if |
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.
I have a few suggestions regarding
- How to compute
steps
- The exact conditional statements
- Code style
- Use `divrem` for computing `steps` in `BMI.update_until` function. The remainder `rem` is used to throw an error message. - take the for loop in function `BMI.update_until` out of the conditional block. Co-authored-by: Carlos Fernando Baptista <[email protected]>
c550628
to
da8948c
Compare
Issue addressed
Fixes #386
Explanation
BMI.update_until
could throw anInexactError: Int64
caused by a not whole number. This is fixed by usingdivrem
for the computation of the number ofsteps
inBMI.update_until
, an error is thrown when the absolute remainder is larger thaneps()
. An error is also thrown whensteps
is a negative number.Checklist
master