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

date2num error when converting a DatetimeProlepticGregorian object in cftime 1.0.4 #126

Closed
spencerkclark opened this issue Oct 22, 2019 · 5 comments

Comments

@spencerkclark
Copy link
Collaborator

In version 1.0.3.4 of cftime the following succeeds without an error:

In [1]: import cftime

In [2]: d = cftime.DatetimeProlepticGregorian(1, 1, 1)

In [3]: cftime.date2num(d, 'days since 0001-01-01', 'proleptic_gregorian')
Out[3]: 0.0

However, with 1.0.4, the following occurs:

In [3]: cftime.date2num(d, 'days since 0001-01-01', 'proleptic_gregorian')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-5b0bfcafe058> in <module>
----> 1 cftime.date2num(d, 'days since 0001-01-01', 'proleptic_gregorian')

cftime/_cftime.pyx in cftime._cftime.date2num()

AttributeError: 'cftime._cftime.DatetimeProlepticGregorian' object has no attribute 'tzinfo'

We came across this in the xarray test suite, xref: pydata/xarray#3427. Was this an intentional change?

@jswhit
Copy link
Collaborator

jswhit commented Oct 22, 2019

Seems to be related to

#110

@barronh, could you take a look?

jswhit added a commit that referenced this issue Oct 22, 2019
@jswhit
Copy link
Collaborator

jswhit commented Oct 22, 2019

Looks like a simple fix for a typo that slipped through in PR #110 (PR #127). Assuming the xarray test suite runs cleanly with this fix, I'll push a 1.0.4.1 release.

@barronh
Copy link
Contributor

barronh commented Oct 23, 2019

I’m at a conference thru tomorrow, so I haven’t been able to look at it. I trust that you’re right. I could look on Thursday.

jswhit added a commit that referenced this issue Oct 23, 2019
@jswhit
Copy link
Collaborator

jswhit commented Oct 23, 2019

Will go ahead and merge since the fix is trivial.

@jswhit
Copy link
Collaborator

jswhit commented Oct 23, 2019

F

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

No branches or pull requests

3 participants