Skip to content

Commit

Permalink
Add a non-ns test for polyval, polyfit
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jan 9, 2025
1 parent c4b2af3 commit 45a0d56
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions xarray/tests/test_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,20 @@ def test_where_attrs() -> None:
),
id="datetime",
),
pytest.param(
# Force a non-ns unit for the coordinate, make sure we convert to `ns`
# for backwards compatibility at the moment. This can be relaxed in the future.
xr.DataArray(
pd.date_range("1970-01-01", freq="s", periods=3, unit="s"), dims="x"
),
xr.DataArray([0, 1], dims="degree", coords={"degree": [0, 1]}),
xr.DataArray(
[0, 1e9, 2e9],
dims="x",
coords={"x": pd.date_range("1970-01-01", freq="s", periods=3)},
),
id="datetime-non-ns",
),
pytest.param(
xr.DataArray(
np.array([1000, 2000, 3000], dtype="timedelta64[ns]"), dims="x"
Expand Down Expand Up @@ -2457,6 +2471,14 @@ def test_polyval_degree_dim_checks() -> None:
xr.DataArray(pd.date_range("1970-01-01", freq="ns", periods=3), dims="x"),
id="datetime",
),
# Force a non-ns unit for the coordinate, make sure we convert to `ns` in both polyfit & polval
# for backwards compatibility at the moment. This can be relaxed in the future.
pytest.param(
xr.DataArray(
pd.date_range("1970-01-01", freq="s", unit="s", periods=3), dims="x"
),
id="datetime-non-ns",
),
pytest.param(
xr.DataArray(np.array([0, 1, 2], dtype="timedelta64[ns]"), dims="x"),
id="timedelta",
Expand Down

0 comments on commit 45a0d56

Please sign in to comment.