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

Change of behaviour due to latest cftime #161

Closed
duncanwp opened this issue Dec 3, 2020 · 2 comments · Fixed by #165 or #168
Closed

Change of behaviour due to latest cftime #161

duncanwp opened this issue Dec 3, 2020 · 2 comments · Fixed by #165 or #168
Assignees

Comments

@duncanwp
Copy link

duncanwp commented Dec 3, 2020

It seems that the latest version of cftime always returns cftime objects, which means that the cf-units documentation is no longer correct and the default behaviour has changed.

Specifically, the only_use_cftime_datetimes option in cftime.num2date defaults to True. I would argue that the cf-units call to this function should set this to be False for the meantime to maintain the current documented expectation that it should return python datetimes where possible. In a future major release it would be better to allow this option (and the accompanying only_use_python_datetimes option) to be passed down the call stack.

@trexfeathers
Copy link
Collaborator

Hi @duncanwp, I've requested some time within my team (which includes several cf-units contributors) to take a look at this. But it's difficult to tell when this will happen, so feel free to put up a PR if you have the time 🙂

@duncanwp
Copy link
Author

Hi @trexfeathers thanks for picking this up! As fas as I can tell this will affect all calls to cftime.num2date. For example:

>>> print(type(cf_units.num2date(100, 'seconds since 1900-01-01', 'gregorian')))
<class 'cftime._cftime.real_datetime'>

Whereas this should be a datetime.datetime.

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