@@ -989,27 +989,41 @@ def test_cftimeindex_calendar_property(calendar, expected):
989
989
990
990
991
991
def test_cftime_noleap_with_str ():
992
- time = xr .cftime_range (' 2000-01-01' , ' 2006-01-01' , freq = 'D' , calendar = ' noleap' )
993
- temperature = np .ones (len (time ))
992
+ time = xr .cftime_range (" 2000-01-01" , " 2006-01-01" , freq = "D" , calendar = " noleap" )
993
+ temperature = np .ones (len (time ))
994
994
da = xr .DataArray (
995
995
data = temperature ,
996
996
dims = ["time" ],
997
- coords = dict (time = time ,),
997
+ coords = dict (
998
+ time = time ,
999
+ ),
998
1000
)
999
- out = da .sel (time = slice ('2001' ,'2002' )) # works if array is built with cftime
1000
- da1 = da .convert_calendar ('noleap' )
1001
- out1 = da1 .sel (time = slice ('2001' ,'2002' )) # works if array is built with cftime and converted
1002
-
1003
- time = pd .date_range ('2000-01-01' ,'2006-01-01' , freq = 'D' ,)
1004
- temperature = np .ones (len (time ))
1001
+ out = da .sel (time = slice ("2001" , "2002" )) # works if array is built with cftime
1002
+ da1 = da .convert_calendar ("noleap" )
1003
+ out1 = da1 .sel (
1004
+ time = slice ("2001" , "2002" )
1005
+ ) # works if array is built with cftime and converted
1006
+
1007
+ time = pd .date_range (
1008
+ "2000-01-01" ,
1009
+ "2006-01-01" ,
1010
+ freq = "D" ,
1011
+ )
1012
+ temperature = np .ones (len (time ))
1005
1013
da2 = xr .DataArray (
1006
1014
data = temperature ,
1007
1015
dims = ["time" ],
1008
- coords = dict (time = time ,),
1016
+ coords = dict (
1017
+ time = time ,
1018
+ ),
1009
1019
)
1010
- out2 = da2 .sel (time = slice ('2001' ,'2002' )) # # works if array is built with pandas time
1011
- da3 = da2 .convert_calendar ('noleap' )
1012
- out3 = da3 .sel (time = slice ('2001' ,'2002' )) # fails if array is built with pandas time and convert to noleap
1020
+ out2 = da2 .sel (
1021
+ time = slice ("2001" , "2002" )
1022
+ ) # # works if array is built with pandas time
1023
+ da3 = da2 .convert_calendar ("noleap" )
1024
+ out3 = da3 .sel (
1025
+ time = slice ("2001" , "2002" )
1026
+ ) # fails if array is built with pandas time and convert to noleap
1013
1027
1014
1028
1015
1029
@requires_cftime
0 commit comments