MCPcopy Index your code
hub / github.com/pydata/xarray / test_dataset_interp_timedelta_variable

Function test_dataset_interp_timedelta_variable

xarray/tests/test_interp.py:1217–1231  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1215
1216@requires_scipy
1217def test_dataset_interp_timedelta_variable() -> None:
1218 # GH#10900
1219 ds = xr.Dataset(
1220 data_vars={
1221 "duration": (["x"], np.array([1, 2, 3, 4, 5], dtype="timedelta64[D]")),
1222 },
1223 coords={"x": np.arange(5)},
1224 )
1225
1226 result = ds.interp(x=[0.5, 1.5, 2.5])
1227
1228 assert "duration" in result.data_vars
1229 expected_seconds = np.array([1.5, 2.5, 3.5]) * 86400
1230 actual_seconds = result["duration"].values.astype("timedelta64[s]").astype(float)
1231 np.testing.assert_allclose(actual_seconds, expected_seconds, rtol=1e-10)
1232
1233
1234@requires_scipy

Callers

nothing calls this directly

Calls 3

interpMethod · 0.95
arangeMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…