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

Compare datetimes instead of strings in _fixes/cmip5/test_access1_X.py #1173

Merged
merged 4 commits into from
Jun 11, 2021

Conversation

valeriupredoi
Copy link
Contributor

@valeriupredoi valeriupredoi commented Jun 11, 2021

Description

Got rid of num2date calls that change the outputted string formatted date everytime there's a new release of cf_units and compare datime objects straight out the box.

Closes #1158

Link to documentation:


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
Copy link

zklaus commented Jun 11, 2021

As @trexfeathers pointed out in the issue, we don't know what we will get back from num2date. That maybe datetime.datetime or cftime.datetime. That makes the comparison with always datetime.datetime fragile, particularly since we use a date long before the Gregorian calendar. Maybe we should use the suggested only_use_cftime_datetimes=True kwarg to num2date and import cftime.datetime instead?

@valeriupredoi
Copy link
Contributor Author

@zklaus fragile is good for testing - that prompts us to look into what's the problem. The thing is, we don't use only cf_time.datetime - we use mostly datetime.datetime in Core, so a test fail would give us a hint there is an issue with the comparison that might stem from different behaviour of cf_time/units vs the datetime module - I think it's good like this, what do you think?

@zklaus
Copy link

zklaus commented Jun 11, 2021

Alright. Sounds good. Let me do a formal review.

@@ -21,6 +21,7 @@ on:
push:
branches:
- main
- compare_datetimes
Copy link

Choose a reason for hiding this comment

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

Remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on it right after the last OSX test passes

@zklaus
Copy link

zklaus commented Jun 11, 2021

Could you please also go through the checklist and assign labels?

@valeriupredoi
Copy link
Contributor Author

all tests had passed, removed the call to test on branch, ready to go go Klaus 🏁

Copy link

@zklaus zklaus left a comment

Choose a reason for hiding this comment

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

Just finish up the checklist please, possibly by removing or striking out not applicable items.

@valeriupredoi valeriupredoi merged commit 4a7e4a5 into main Jun 11, 2021
@valeriupredoi valeriupredoi deleted the compare_datetimes branch June 11, 2021 13:57
@valeriupredoi
Copy link
Contributor Author

done, cheers for the review, Klaus! I think we're now good in terms of all the test fails, on various platforms, a release will be clean 🥇

@zklaus
Copy link

zklaus commented Jun 11, 2021

Cheers V, great work these days! (And all others too, of course 😝 )

@valeriupredoi
Copy link
Contributor Author

🍺 🍺 🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cf-units=2.1.5 for OSX still preserves older version behaviour (<2.1.4)
2 participants