Skip to content

Commit c939730

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9c0967e commit c939730

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

xarray/tests/test_cftimeindex.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -989,27 +989,41 @@ def test_cftimeindex_calendar_property(calendar, expected):
989989

990990

991991
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))
994994
da = xr.DataArray(
995995
data=temperature,
996996
dims=["time"],
997-
coords=dict(time=time,),
997+
coords=dict(
998+
time=time,
999+
),
9981000
)
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))
10051013
da2 = xr.DataArray(
10061014
data=temperature,
10071015
dims=["time"],
1008-
coords=dict(time=time,),
1016+
coords=dict(
1017+
time=time,
1018+
),
10091019
)
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
10131027

10141028

10151029
@requires_cftime

0 commit comments

Comments
 (0)