Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 29, 2024
1 parent 9c0967e commit c939730
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions xarray/tests/test_cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,27 +989,41 @@ def test_cftimeindex_calendar_property(calendar, expected):


def test_cftime_noleap_with_str():
time=xr.cftime_range('2000-01-01','2006-01-01', freq='D', calendar='noleap')
temperature = np.ones(len(time))
time = xr.cftime_range("2000-01-01", "2006-01-01", freq="D", calendar="noleap")
temperature = np.ones(len(time))
da = xr.DataArray(
data=temperature,
dims=["time"],
coords=dict(time=time,),
coords=dict(
time=time,
),
)
out=da.sel(time=slice('2001','2002')) # works if array is built with cftime
da1=da.convert_calendar('noleap')
out1=da1.sel(time=slice('2001','2002')) # works if array is built with cftime and converted

time=pd.date_range('2000-01-01','2006-01-01', freq='D',)
temperature = np.ones(len(time))
out = da.sel(time=slice("2001", "2002")) # works if array is built with cftime
da1 = da.convert_calendar("noleap")
out1 = da1.sel(
time=slice("2001", "2002")
) # works if array is built with cftime and converted

time = pd.date_range(
"2000-01-01",
"2006-01-01",
freq="D",
)
temperature = np.ones(len(time))
da2 = xr.DataArray(
data=temperature,
dims=["time"],
coords=dict(time=time,),
coords=dict(
time=time,
),
)
out2=da2.sel(time=slice('2001','2002')) # # works if array is built with pandas time
da3=da2.convert_calendar('noleap')
out3=da3.sel(time=slice('2001','2002')) # fails if array is built with pandas time and convert to noleap
out2 = da2.sel(
time=slice("2001", "2002")
) # # works if array is built with pandas time
da3 = da2.convert_calendar("noleap")
out3 = da3.sel(
time=slice("2001", "2002")
) # fails if array is built with pandas time and convert to noleap


@requires_cftime
Expand Down

0 comments on commit c939730

Please sign in to comment.