Skip to content

Commit 30a01c8

Browse files
committed
simplify test
1 parent fd7a76c commit 30a01c8

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

xarray/tests/test_cftimeindex.py

+4-25
Original file line numberDiff line numberDiff line change
@@ -988,9 +988,10 @@ def test_cftimeindex_calendar_property(calendar, expected):
988988
assert index.calendar == expected
989989

990990

991+
@requires_cftime
991992
def test_cftime_noleap_with_str():
992993
# https://github.com/pydata/xarray/issues/9138
993-
time = xr.cftime_range("2000-01-01", "2006-01-01", freq="D", calendar="noleap")
994+
time = pd.date_range("2000-01-01", "2006-01-01", freq="D")
994995
temperature = np.ones(len(time))
995996
da = xr.DataArray(
996997
data=temperature,
@@ -999,30 +1000,8 @@ def test_cftime_noleap_with_str():
9991000
time=time,
10001001
),
10011002
)
1002-
# works if array is built with cftime
1003-
out = da.sel(time=slice("2001", "2002"))
1004-
da1 = da.convert_calendar("noleap")
1005-
# works if array is built with cftime and converted
1006-
out1 = da1.sel(time=slice("2001", "2002"))
1007-
1008-
time = pd.date_range(
1009-
"2000-01-01",
1010-
"2006-01-01",
1011-
freq="D",
1012-
)
1013-
temperature = np.ones(len(time))
1014-
da2 = xr.DataArray(
1015-
data=temperature,
1016-
dims=["time"],
1017-
coords=dict(
1018-
time=time,
1019-
),
1020-
)
1021-
# works if array is built with pandas time
1022-
out2 = da2.sel(time=slice("2001", "2002"))
1023-
da3 = da2.convert_calendar("noleap")
1024-
# fails if array is built with pandas time and convert to noleap
1025-
out3 = da3.sel(time=slice("2001", "2002"))
1003+
da_noleap = da.convert_calendar("noleap")
1004+
da_noleap.sel(time=slice("2001", "2002"))
10261005

10271006

10281007
@requires_cftime

0 commit comments

Comments
 (0)