Skip to content

Commit

Permalink
Add basic 1d test
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Dec 14, 2024
1 parent 72de81e commit c5a67a5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion xarray/tests/test_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,28 @@ def test_interp1d_complex_out_of_bounds() -> None:


@requires_scipy
def test_interp_non_numeric() -> None:
def test_interp_non_numeric_1d() -> None:
ds = xr.Dataset(
{
"numeric": ("time", 1 + np.arange(0, 4, 1)),
"non_numeric": ("time", np.array(["a", "b", "c", "d"])),
},
coords={"time": (np.arange(0, 4, 1))},
)
actual = ds.interp(time=np.linspace(0, 3, 7))

expected = xr.Dataset(
{
"numeric": ("time", 1 + np.linspace(0, 3, 7)),
"non_numeric": ("time", np.array(["a", "b", "b", "c", "c", "d", "d"])),
},
coords={"time": np.linspace(0, 3, 7)},
)
xr.testing.assert_identical(actual, expected)


@requires_scipy
def test_interp_non_numeric_nd() -> None:
# regression test for GH8099, GH9839
ds = xr.Dataset({"x": ("a", np.arange(4))}, coords={"a": (np.arange(4) - 1.5)})
t = xr.DataArray(
Expand Down

0 comments on commit c5a67a5

Please sign in to comment.