(method: InterpOptions, case: int)
| 433 | "case", [pytest.param(0, id="no_chunk"), pytest.param(1, id="chunk_y")] |
| 434 | ) |
| 435 | def test_interpolate_scalar(method: InterpOptions, case: int) -> None: |
| 436 | if not has_dask and case == 1: |
| 437 | pytest.skip("dask is not installed in the environment.") |
| 438 | |
| 439 | da = get_example_data(case) |
| 440 | xdest = 0.4 |
| 441 | |
| 442 | actual = da.interp(x=xdest, method=method) |
| 443 | |
| 444 | # scipy interpolation for the reference |
| 445 | def func(obj, new_x): |
| 446 | return scipy.interpolate.interp1d( |
| 447 | da["x"], |
| 448 | obj.data, |
| 449 | axis=obj.get_axis_num("x"), |
| 450 | bounds_error=False, |
| 451 | fill_value=np.nan, |
| 452 | kind=method, # type: ignore[arg-type,unused-ignore] |
| 453 | )(new_x) |
| 454 | |
| 455 | coords = {"x": xdest, "y": da["y"], "x2": func(da["x2"], xdest)} |
| 456 | expected = xr.DataArray(func(da, xdest), dims=["y"], coords=coords) |
| 457 | assert_allclose(actual, expected) |
| 458 | |
| 459 | |
| 460 | @requires_scipy |
nothing calls this directly
no test coverage detected
searching dependent graphs…