-
Notifications
You must be signed in to change notification settings - Fork 50
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
Adopt microsecond precision in num2date and date2num #184
Conversation
@rcomer Let's rebase and respin. I'm happy to then test this with Sound like a reasonable plan? 🤔 |
ce4717e
to
ae2fe3b
Compare
Thanks @bjlittle I have rebased and also removed your retrospectively added tests - I forgot this branch predated those, but you just can't test what isn't there any more! Remaining test failures appear to be as before i.e. expecting a whole number of seconds out when a fraction of seconds is passed in. |
I ran the Iris tests locally under py3.10 with this branch pip-installed. All passed ✅👍 |
@rcomer Okay, so this seems like a reasonable time to polish and bank this. I'm convinced that we should go for the removal of the rounding behaviour. Since there is no downstream side-effects from testing with I removed the decision required label, so go for it! 🚀 Simply show the PR some love, and extend the test coverage enough to convince ourselves that the You happy to do that? |
2783cec
to
6aed27e
Compare
6aed27e
to
3983b79
Compare
OK I think this might be there. I'm a bit unclear where the tests should be but they are easy enough to block move if needed. Can confirm that Iris tests still pass with latest version of this branch. |
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.
@rcomer Awesome refactor.
Thanks for having the patience of a saint 👼
🚀 Pull Request
Description
The
_discard_microsecond
and_num2date_to_nearest_second
functions were introduced at #66 and ensure that we always work at second precision. The stated reason for this wasSince then, we have switched to using
cftime
under the hood (#85) and a quick search of thecftime
repo suggests that they have worked on getting their functions working at microsecond precision (e.g. Unidata/cftime#187, Unidata/cftime#171). So it seems plausible that the rounding errors mentioned in #66 may no longer be a problem. This PR simply removes the microsecond handling from our functions to see which tests fail. The only failures are for tests that specifically use fractions of a second, and the values produced all look sensible to me:Values produced within failing tests
test_discard_mircosecond
gives
test_fractional_second_*
gives
So I can't see any evidence from the
cf_units
tests that rounding is still a problem.If we were to strip out these functions and revert to
cftime
's microsecond precision, we would benefit from a simpler, easier to maintain codebase.Thoughts?