-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Calendar utilities #5233
Calendar utilities #5233
Conversation
I am excessively confused at the errors in the builds... They are triggered by tests not touching my work and also it says the installed version of xarray is 0.11??? |
where do you see that? The only thing I see is a failed docs build, which fails because you used |
I see the strange errors here : https://github.com/aulemahal/xarray/actions. The failure triggered an email and this is why I didn't look here. Well, if it's something in the configuration of my fork, then we don't care! Will fix the doc errors... |
I think that's because you didn't push the newer tags, so while you get the latest commits In any case, the action shouldn't run (it should either be skipped or not run at all). Actually, I'd recommend to disable action runs on your fork (this is possible somewhere in the repository settings) because it doesn't really make sense to run the actions multiple times. |
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 not checked the whole PR but left some small comments anyway.
I can see that the functionalities build on each other but it would be easier to review if it was split into two or three PRs (e.g. DataArray.dt.calendar
and the rest). But don't do that right now - lets see what @spencerkclark thinks.
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.
Thanks @aulemahal -- it will take me a few more passes to fully review this -- sorry for being a bit slow, but here are a few initial comments.
Updated the code following first wave of suggestions! |
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.
Thanks for the nice updates @aulemahal. I made another pass and left a few more comments. Regarding your initial questions:
I'm not sure where to expose the function. Should the range-generators be accessible directly like
xr.date_range
?
Yes, I think this makes the most sense, considering that cftime_range
is accessible from a similar place.
The
convert_calendar
andinterp_calendar
could be implemented as methods ofDataArray
andDataset
, should I do that?
My thought would be to say yes to this as well. Both require a DataArray or Dataset as input and resemble reindexing or interpolation operations.
Co-authored-by: Spencer Clark <[email protected]>
Hello @aulemahal! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-10-26 20:04:00 UTC |
@spencerkclark Applied suggestions from the review, added Wasn't sure what to do with the tests. They already done in |
Co-authored-by: Spencer Clark <[email protected]>
@spencerkclark Done! Note that we have this issue : Ouranosinc/xclim#841 open on our side. It's for a third method for converting 360_day calendars. Based on something used in the litterature, it randomizes the days to insert/drop when converting. My plan is to implement it in xclim soonish, then if it works I could bring it up here and open a new PR. |
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.
Awesome, thanks @aulemahal. The tests you added for the errors look great. I have a few more suggestions for making some of the other tests a little stronger, and a question about the behavior of convert_calendar
.
Here we are! Also, I don't think the test failure comes from my changes. |
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.
OK @aulemahal, I gave this another look over today and I think this may be ready to go -- just address these last few docstring nits and merge main
. I'll leave it open for the next few days in case others would like to have a look, but if I do not hear anything before the end of Wednesday, I will go ahead and merge this on Thursday morning.
Co-authored-by: Spencer Clark <[email protected]>
Thanks @aulemahal! |
pre-commit run --all-files
whats-new.rst
api.rst
So:
Added
coding.cftime_offsets.date_range
andcoding.cftime_offsets.date_range_like
The first simply swtiches between
pd.date_range
andxarray.cftime_range
according to the arguments. The second infers start, end and freq from an existing datetime array and returns a similar range in another calendar.Added
coding/calendar_ops.py
withconvert_calendar
andinterp_calendar
Didn't know where to put them, so there they are.
Added
DataArray.dt.calendar
.When the datetime objects are backed by numpy, it always return
"proleptic_gregorian"
.I'm not sure where to expose the function. Should the range-generators be accessible directly like
xr.date_range
?The
convert_calendar
andinterp_calendar
could be implemented as methods ofDataArray
andDataset
, should I do that?