Skip to content

Commit feaccc4

Browse files
authored
cftime: 'gregorian' -> 'standard' [test-upstream] (#6082)
1 parent f7bfd21 commit feaccc4

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

xarray/tests/test_cftimeindex.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,23 @@
1717
)
1818
from xarray.tests import assert_array_equal, assert_identical
1919

20-
from . import requires_cftime
20+
from . import has_cftime, requires_cftime
2121
from .test_coding_times import (
2222
_ALL_CALENDARS,
2323
_NON_STANDARD_CALENDARS,
2424
_all_cftime_date_types,
2525
)
2626

27+
# cftime 1.5.2 renames "gregorian" to "standard"
28+
standard_or_gregorian = ""
29+
if has_cftime:
30+
import cftime
31+
32+
if LooseVersion(cftime.__version__) >= LooseVersion("1.5.2"):
33+
standard_or_gregorian = "standard"
34+
else:
35+
standard_or_gregorian = "gregorian"
36+
2737

2838
def date_dict(year=None, month=None, day=None, hour=None, minute=None, second=None):
2939
return dict(
@@ -929,7 +939,8 @@ def test_cftimeindex_shift_invalid_freq():
929939
("365_day", "noleap"),
930940
("360_day", "360_day"),
931941
("julian", "julian"),
932-
("gregorian", "gregorian"),
942+
("gregorian", standard_or_gregorian),
943+
("standard", standard_or_gregorian),
933944
("proleptic_gregorian", "proleptic_gregorian"),
934945
],
935946
)
@@ -946,7 +957,8 @@ def test_cftimeindex_calendar_property(calendar, expected):
946957
("365_day", "noleap"),
947958
("360_day", "360_day"),
948959
("julian", "julian"),
949-
("gregorian", "gregorian"),
960+
("gregorian", standard_or_gregorian),
961+
("standard", standard_or_gregorian),
950962
("proleptic_gregorian", "proleptic_gregorian"),
951963
],
952964
)
@@ -983,20 +995,20 @@ def test_cftimeindex_freq_in_repr(freq, calendar):
983995
[
984996
(
985997
2,
986-
"""\
998+
f"""\
987999
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00],
988-
dtype='object', length=2, calendar='gregorian', freq=None)""",
1000+
dtype='object', length=2, calendar='{standard_or_gregorian}', freq=None)""",
9891001
),
9901002
(
9911003
4,
992-
"""\
1004+
f"""\
9931005
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
9941006
2000-01-04 00:00:00],
995-
dtype='object', length=4, calendar='gregorian', freq='D')""",
1007+
dtype='object', length=4, calendar='{standard_or_gregorian}', freq='D')""",
9961008
),
9971009
(
9981010
101,
999-
"""\
1011+
f"""\
10001012
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
10011013
2000-01-04 00:00:00, 2000-01-05 00:00:00, 2000-01-06 00:00:00,
10021014
2000-01-07 00:00:00, 2000-01-08 00:00:00, 2000-01-09 00:00:00,
@@ -1006,7 +1018,7 @@ def test_cftimeindex_freq_in_repr(freq, calendar):
10061018
2000-04-04 00:00:00, 2000-04-05 00:00:00, 2000-04-06 00:00:00,
10071019
2000-04-07 00:00:00, 2000-04-08 00:00:00, 2000-04-09 00:00:00,
10081020
2000-04-10 00:00:00],
1009-
dtype='object', length=101, calendar='gregorian', freq='D')""",
1021+
dtype='object', length=101, calendar='{standard_or_gregorian}', freq='D')""",
10101022
),
10111023
],
10121024
)

0 commit comments

Comments
 (0)