Skip to content

Commit

Permalink
skip test for certain xarray versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mathause committed Sep 7, 2023
1 parent affa0e3 commit 55d3e26
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/unit/test_smoothing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pandas as pd
import pytest
import xarray as xr
from packaging.version import Version
from statsmodels.nonparametric.smoothers_lowess import lowess

import mesmer.stats.smoothing
Expand All @@ -26,18 +28,21 @@ def test_lowess_errors():
mesmer.stats.smoothing.lowess(data.to_dataset(), "lat", n_steps=40)

# numpy datetime
time = xr.date_range("2000-01-01", periods=30)
time = pd.date_range("2000-01-01", periods=30)
data = data.assign_coords(time=time)

with pytest.raises(TypeError, match="Cannot convert coords"):
mesmer.stats.smoothing.lowess(data.to_dataset(), "time", frac=0.5)

# cftime datetime
time = xr.date_range("2000-01-01", periods=30, calendar="noleap")
data = data.assign_coords(time=time)
# TODO: remove check once we drop python 3.7
if Version(xr.__version__) >= Version("21.0"):

with pytest.raises(TypeError, match="Cannot convert coords"):
mesmer.stats.smoothing.lowess(data.to_dataset(), "time", frac=0.5)
# cftime datetime
time = xr.date_range("2000-01-01", periods=30, calendar="noleap")
data = data.assign_coords(time=time)

with pytest.raises(TypeError, match="Cannot convert coords"):
mesmer.stats.smoothing.lowess(data.to_dataset(), "time", frac=0.5)


@pytest.mark.parametrize("it", [0, 3])
Expand Down

0 comments on commit 55d3e26

Please sign in to comment.