Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverhiggs committed Sep 3, 2024
1 parent 0d37fdd commit 6801b79
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import datetime
import operator
import warnings
from unittest import mock
Expand Down Expand Up @@ -1813,6 +1814,30 @@ def resample_as_pandas(array, *args, **kwargs):
with pytest.raises(ValueError):
reverse.resample(time="1D").mean()

@pytest.mark.parametrize("use_cftime", [True, False])
def test_resample_dtype(self, use_cftime: bool) -> None:
if use_cftime and not has_cftime:
pytest.skip()
array = DataArray(
np.arange(10),
[
(
"time",
xr.date_range(
"2000-01-01", freq="6h", periods=10, use_cftime=use_cftime
),
)
],
)
test_resample_freqs = [
"10min",
pd.Timedelta(hours=2),
pd.offsets.MonthBegin(),
datetime.timedelta(days=1, hours=6),
]
for freq in test_resample_freqs:
array.resample(time=freq)

@pytest.mark.parametrize("use_cftime", [True, False])
def test_resample_doctest(self, use_cftime: bool) -> None:
# run the doctest example here so we are not surprised
Expand Down

0 comments on commit 6801b79

Please sign in to comment.