Skip to content
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

Add a custom date2num function to deal with changes in cftime #1373

Merged
merged 12 commits into from
Oct 27, 2021
Merged

Conversation

zklaus
Copy link

@zklaus zklaus commented Oct 27, 2021

Description

Closes #1372


Before you get started

Checklist

It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.


To help with the number pull requests:

@zklaus zklaus requested a review from jvegreg as a code owner October 27, 2021 12:30
@codecov
Copy link

codecov bot commented Oct 27, 2021

Codecov Report

Merging #1373 (68dc5bf) into main (639e5ab) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1373      +/-   ##
==========================================
+ Coverage   88.37%   88.39%   +0.01%     
==========================================
  Files         195      195              
  Lines        9943     9958      +15     
==========================================
+ Hits         8787     8802      +15     
  Misses       1156     1156              
Impacted Files Coverage Δ
esmvalcore/cmor/_fixes/cmip5/gfdl_cm2p1.py 83.33% <100.00%> (+0.40%) ⬆️
esmvalcore/cmor/_fixes/cmip6/fgoals_f3_l.py 86.95% <100.00%> (+0.59%) ⬆️
esmvalcore/cmor/_fixes/icon/icon.py 100.00% <100.00%> (ø)
esmvalcore/cmor/_fixes/native6/era5.py 90.75% <100.00%> (+0.03%) ⬆️
esmvalcore/cmor/_fixes/native6/mswep.py 77.46% <100.00%> (+0.32%) ⬆️
esmvalcore/cmor/check.py 97.72% <100.00%> (+<0.01%) ⬆️
esmvalcore/iris_helpers.py 100.00% <100.00%> (ø)
esmvalcore/preprocessor/_multimodel.py 95.00% <100.00%> (+0.03%) ⬆️
esmvalcore/preprocessor/_time.py 94.75% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 639e5ab...68dc5bf. Read the comment docs.

@valeriupredoi
Copy link
Contributor

cheers @zklaus - tests/unit/preprocessor/_multimodel/test_multimodel.py is still using num2date (not date2num) - do you think we should use the num2date from iris too? It's the reciprocal function so it's a sensible idea methinks

@zklaus
Copy link
Author

zklaus commented Oct 27, 2021

@valeriupredoi, it's not a bad idea per se, but since this is a hotfix and num2date doesn't suffer from the problem, let's defer that. Feel free to open an issue about it.

@zklaus zklaus changed the title Date2num Add a custom date2num function to deal with changes in cftime Oct 27, 2021
@zklaus zklaus added bug Something isn't working iris Related to the Iris package release labels Oct 27, 2021
Copy link
Contributor

@valeriupredoi valeriupredoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to see cftime go at least just for date2num - we still have two instances of importing and using the module in cmor/_fixes/cmip6/fgoals_f3_l.py and cmor/_fixes/cmip5/gfdl_cm2p1.py and one test in tests/unit/preprocessor/_multimodel/test_multimodel.py - I think we can make sure those get replaced too (maybe, not sure about cftime.DatetimeJulian or cftime.DatetimeNoLeap), but anyway that'd be done in a separate PR. Klaus, could you add a docstring to the new helper function (bit of say why we use that), all good by me other than that 🍺

@valeriupredoi
Copy link
Contributor

@zklaus yer, will do, given how shifty-mcshiftface cftime is I' be quite happy to see if we can wholly get rid of it 👍

@zklaus zklaus added this to the v2.4.0 milestone Oct 27, 2021
@zklaus
Copy link
Author

zklaus commented Oct 27, 2021

I'll just add a test and then we're good to go.

@valeriupredoi
Copy link
Contributor

I'll just add a test and then we're good to go.

yeah could do, but that's tested via iris so maybe even no need

@zklaus zklaus merged commit 6495cc3 into main Oct 27, 2021
@zklaus zklaus deleted the date2num branch October 27, 2021 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iris Related to the Iris package release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return type of cftime.date2num might be wrong
3 participants