17
17
)
18
18
from xarray .tests import assert_array_equal , assert_identical
19
19
20
- from . import requires_cftime
20
+ from . import has_cftime , requires_cftime
21
21
from .test_coding_times import (
22
22
_ALL_CALENDARS ,
23
23
_NON_STANDARD_CALENDARS ,
24
24
_all_cftime_date_types ,
25
25
)
26
26
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
+
27
37
28
38
def date_dict (year = None , month = None , day = None , hour = None , minute = None , second = None ):
29
39
return dict (
@@ -929,7 +939,8 @@ def test_cftimeindex_shift_invalid_freq():
929
939
("365_day" , "noleap" ),
930
940
("360_day" , "360_day" ),
931
941
("julian" , "julian" ),
932
- ("gregorian" , "gregorian" ),
942
+ ("gregorian" , standard_or_gregorian ),
943
+ ("standard" , standard_or_gregorian ),
933
944
("proleptic_gregorian" , "proleptic_gregorian" ),
934
945
],
935
946
)
@@ -946,7 +957,8 @@ def test_cftimeindex_calendar_property(calendar, expected):
946
957
("365_day" , "noleap" ),
947
958
("360_day" , "360_day" ),
948
959
("julian" , "julian" ),
949
- ("gregorian" , "gregorian" ),
960
+ ("gregorian" , standard_or_gregorian ),
961
+ ("standard" , standard_or_gregorian ),
950
962
("proleptic_gregorian" , "proleptic_gregorian" ),
951
963
],
952
964
)
@@ -983,20 +995,20 @@ def test_cftimeindex_freq_in_repr(freq, calendar):
983
995
[
984
996
(
985
997
2 ,
986
- """\
998
+ f """\
987
999
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)""" ,
989
1001
),
990
1002
(
991
1003
4 ,
992
- """\
1004
+ f """\
993
1005
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
994
1006
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')""" ,
996
1008
),
997
1009
(
998
1010
101 ,
999
- """\
1011
+ f """\
1000
1012
CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
1001
1013
2000-01-04 00:00:00, 2000-01-05 00:00:00, 2000-01-06 00:00:00,
1002
1014
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):
1006
1018
2000-04-04 00:00:00, 2000-04-05 00:00:00, 2000-04-06 00:00:00,
1007
1019
2000-04-07 00:00:00, 2000-04-08 00:00:00, 2000-04-09 00:00:00,
1008
1020
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')""" ,
1010
1022
),
1011
1023
],
1012
1024
)
0 commit comments