diff --git a/src/pyinterp/backends/xarray.py b/src/pyinterp/backends/xarray.py index 3305a6f2..fa314c18 100644 --- a/src/pyinterp/backends/xarray.py +++ b/src/pyinterp/backends/xarray.py @@ -501,7 +501,8 @@ def __call__(self, method: str = 'bilinear', bounds_error: bool = False, bicubic_kwargs: Optional[Dict] = None, - num_threads: int = 0) -> numpy.ndarray: + num_threads: int = 0, + **kwargs) -> numpy.ndarray: """Interpolation at coordinates. Args: @@ -520,6 +521,11 @@ def __call__(self, num_threads: The number of threads to use for the computation. If 0 all CPUs are used. If 1 is given, no parallel computing code is used at all, which is useful for debugging. Defaults to ``0``. + **kwargs: List of keyword arguments provided to the interpolation + method :py:meth:`pyinterp.bivariate `, + :py:meth:`pyinterp.trivariate ` or + :py:meth:`pyinterp.quadrivariate ` + depending on the number of dimensions of the grid. Returns: New array on the new coordinates. """ @@ -532,4 +538,5 @@ def __call__(self, return self._interp(coords, interpolator=method, bounds_error=bounds_error, - num_threads=num_threads) + num_threads=num_threads, + **kwargs) diff --git a/src/pyinterp/tests/test_2d.py b/src/pyinterp/tests/test_2d.py index 4a6e1475..a1fff4f0 100644 --- a/src/pyinterp/tests/test_2d.py +++ b/src/pyinterp/tests/test_2d.py @@ -111,6 +111,15 @@ def test_biavariate(pytestconfig): z = grid(collections.OrderedDict(lon=x.ravel(), lat=y.ravel()), method='bilinear') assert isinstance(z, np.ndarray) + z = grid(collections.OrderedDict(lon=x.ravel(), lat=y.ravel()), + method='inverse_distance_weighting', + p=1) + assert isinstance(z, np.ndarray) + + with pytest.raises(TypeError): + z = grid(collections.OrderedDict(lon=x.ravel(), lat=y.ravel()), + method='nearest', + p=1) # This is necessary in order for Dask to scatter the callable instances. other = pickle.loads(pickle.dumps(grid, protocol=0))