Skip to content

cftime: 'gregorian' -> 'standard' [test-upstream] #6082

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

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions xarray/tests/test_cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,23 @@
)
from xarray.tests import assert_array_equal, assert_identical

from . import requires_cftime
from . import has_cftime, requires_cftime
from .test_coding_times import (
_ALL_CALENDARS,
_NON_STANDARD_CALENDARS,
_all_cftime_date_types,
)

# cftime 1.5.2 renames "gregorian" to "standard"
standard_or_gregorian = ""
if has_cftime:
import cftime

if LooseVersion(cftime.__version__) >= LooseVersion("1.5.2"):
standard_or_gregorian = "standard"
else:
standard_or_gregorian = "gregorian"


def date_dict(year=None, month=None, day=None, hour=None, minute=None, second=None):
return dict(
Expand Down Expand Up @@ -929,7 +939,8 @@ def test_cftimeindex_shift_invalid_freq():
("365_day", "noleap"),
("360_day", "360_day"),
("julian", "julian"),
("gregorian", "gregorian"),
("gregorian", standard_or_gregorian),
("standard", standard_or_gregorian),
("proleptic_gregorian", "proleptic_gregorian"),
],
)
Expand All @@ -946,7 +957,8 @@ def test_cftimeindex_calendar_property(calendar, expected):
("365_day", "noleap"),
("360_day", "360_day"),
("julian", "julian"),
("gregorian", "gregorian"),
("gregorian", standard_or_gregorian),
("standard", standard_or_gregorian),
("proleptic_gregorian", "proleptic_gregorian"),
],
)
Expand Down Expand Up @@ -983,20 +995,20 @@ def test_cftimeindex_freq_in_repr(freq, calendar):
[
(
2,
"""\
f"""\
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00],
dtype='object', length=2, calendar='gregorian', freq=None)""",
dtype='object', length=2, calendar='{standard_or_gregorian}', freq=None)""",
),
(
4,
"""\
f"""\
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
2000-01-04 00:00:00],
dtype='object', length=4, calendar='gregorian', freq='D')""",
dtype='object', length=4, calendar='{standard_or_gregorian}', freq='D')""",
),
(
101,
"""\
f"""\
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
2000-01-04 00:00:00, 2000-01-05 00:00:00, 2000-01-06 00:00:00,
2000-01-07 00:00:00, 2000-01-08 00:00:00, 2000-01-09 00:00:00,
Expand All @@ -1006,7 +1018,7 @@ def test_cftimeindex_freq_in_repr(freq, calendar):
2000-04-04 00:00:00, 2000-04-05 00:00:00, 2000-04-06 00:00:00,
2000-04-07 00:00:00, 2000-04-08 00:00:00, 2000-04-09 00:00:00,
2000-04-10 00:00:00],
dtype='object', length=101, calendar='gregorian', freq='D')""",
dtype='object', length=101, calendar='{standard_or_gregorian}', freq='D')""",
),
],
)
Expand Down