-
Notifications
You must be signed in to change notification settings - Fork 49
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
Support gregorian to standard calendar change #205
Conversation
Thanks for submitting this @larsbarring! I was taking a look and I wondered if the changes to |
Yeah, but it remains to be seen. The unit tests fails miserably (I am a complete rookie at these). And I have no insight regarding possible downstream dependencies |
The traceback is the same error we have been seeing recently during documentation builds, so we can definitely say it's not resulting in changes you have made. Unfortunately I am also clueless to the fix at the moment! |
96a7591
to
01918ab
Compare
Thanks, I have something for #185 in the pipeline, but it uses this change. |
@trexfeathers @bjlittle Any chance the unit test problem might be fixed reasonably soon? That is, soon enough that the upcoming iris 3.2.0 will use cf-units with this fix implemented. |
We've seen your message 🙂. We'll have a better idea of the answer in the next week. |
Rebasing onto main should resolve the unit test problem @larsbarring |
I've just been checking locally and there are some actual unit test failures relating to the changes, but they look fairly simple 🙂 We'll see the detail once this is rebased. |
01918ab
to
8da49d1
Compare
The linting failure I am not sure what to do about. And now two of the three initial test failures have been fixed. The third one is a bit more complicated. It seems that in |
I think maybe we need to do for |
@larsbarring are you using pre-commit/black locally? I know we haven't made this expectation obvious. |
hrm ... probably not as it seems, at least not correctly configured .... |
@larsbarring if you install pre-commit in your development environment I think it should "just work" whenever you make a commit 🤞 |
Hm, this is becoming a bit too complex. The pre-commit black gives the same uninformative error, and seems to have reformatted lines that I have not touched L. 846-849, as well as L 1816-1819 where I changed the calendar. |
I see what @rcomer is saying now. I've asked if anyone in the team has some time to look at this. Thanks, as ever, for your patience @larsbarring 😬 |
Done, thanks to @wjbenfold ❤. @larsbarring if you bring in the latest |
5fd4745
to
211c276
Compare
Linting failure solved -- thanks @wjbenfold, @trexfeathers, @rcomer ! The remaining test failure is because of Unit.num2date returns gregorian calendar:
Here is a quick hack to show the problem: import cftime
import cf_units as unit
Unit = unit.Unit
u = Unit(
"hours since 2010-11-02 12:00:00", calendar=unit.CALENDAR_GREGORIAN
)
print("repr(u) = ", repr(u))
res = u.num2date(1)
print("repr(res) = ", repr(res))
print("res.calendar = ", res.calendar)
# repr(u) = Unit('hours since 2010-11-02 12:00:00', calendar='standard')
# repr(res) = cftime.DatetimeGregorian(2010, 11, 2, 13, 0, 0, 0, has_year_zero=False)
# res.calendar = gregorian And I do not know whether to wait for |
As far as I can tell, it's impossible to create a standard calendar datetime instance with the current
So I think the only way to get Perhaps it doesn't matter. Since you are looking at the CF Conventions, I guess your main concern is how NetCDF files are written? I have an existing NetCDF file that was saved by a previous Iris version. The time coordinate looks like this with
I made an environment with your branch and Iris v3.1. I used this to load and re-save my file. Now the
So for NetCDF saving, the change seems to be having the desired effect. So one option may be to revert the expected value of the There may be other considerations that I am missing. What do others think? |
My main reason for pushing this issue, except for the general argument that it is nice to follow CF, is that we need to concatenate data from different sources that happens to have different calendars (#185). But in a PR to solve that issue I could include tests of both calendars (that later could compacted once a new version of cftime is available). |
@SciTools/cf-units-devs I believe these tests should now pass with the latest version of |
TBH not sure we can get this banked in time for If banking this PR forces subsequent changes upstream within Sound like a reasonable plan? |
It looks like if a py3.9 lockfile already exists, it refuses to overwrite it even if the build number gets bumped, so I'm not sure @rcomer |
Ok, I think if you rebase onto main then we can hopefully get the CI passing @larsbarring. Then we can move to reviewing with confidence that what's here passes the tests |
9432a01
to
8eefa23
Compare
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## main #205 +/- ##
=======================================
Coverage 91.05% 91.05%
=======================================
Files 6 6
Lines 816 816
Branches 121 121
=======================================
Hits 743 743
Misses 61 61
Partials 12 12
Continue to review full report at Codecov.
|
Pretty nice to see this passing the checks. Thanks all, for helping me with setting up these these tools :-) |
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.
@larsbarring Awesome! Thanks so much 💯 🍻
Note for the interested - having run the Iris tests with current cf-units main (with this change) and current Iris, the tests all pass. We can jump up and down on it a bit more after the next cf-units release to double-check but it's looking good :) |
I've also tried running the Iris tests with this and did get failures, so not sure what we're doing differently. The good news is those failures were easy to fix with find-and-replace within Iris. |
🚀 Pull Request
Description
Change definitive form of calendar from
gregorian
tostandard
, instead of the other way around.With first time attempt at [change of ] unit tests for this.