diff --git a/pygmt/src/grdfill.py b/pygmt/src/grdfill.py index 1492e1e9c73..40818a8f4d5 100644 --- a/pygmt/src/grdfill.py +++ b/pygmt/src/grdfill.py @@ -2,7 +2,6 @@ grdfill - Interpolate across holes in a grid. """ -import warnings from collections.abc import Sequence from typing import Literal @@ -23,14 +22,12 @@ def _validate_params( neighbor_fill=None, spline_fill=None, inquire=False, - mode=None, ): """ Validate the fill/inquire parameters. >>> _validate_params(constant_fill=20.0) >>> _validate_params(inquire=True) - >>> _validate_params(mode="c20.0") >>> _validate_params(constant_fill=20.0, grid_fill="bggrid.nc") Traceback (most recent call last): ... @@ -45,13 +42,6 @@ def _validate_params( pygmt.exceptions.GMTInvalidInput: Need to specify parameter ... """ _fill_params = "'constant_fill'/'grid_fill'/'neighbor_fill'/'spline_fill'" - # The deprecated 'mode' parameter is given. - if mode is not None: - msg = ( - "The 'mode' parameter is deprecated since v0.15.0 and will be removed in " - f"v0.19.0. Use {_fill_params} instead." - ) - warnings.warn(msg, FutureWarning, stacklevel=2) n_given = sum( param is not None and param is not False @@ -61,11 +51,10 @@ def _validate_params( neighbor_fill, spline_fill, inquire, - mode, ] ) if n_given > 1: # More than one mutually exclusive parameter is given. - msg = f"Parameters {_fill_params}/'inquire'/'mode' are mutually exclusive." + msg = f"Parameters {_fill_params}/'inquire' are mutually exclusive." raise GMTInvalidInput(msg) if n_given == 0: # No parameters are given. msg = ( @@ -76,7 +65,6 @@ def _validate_params( @fmt_docstring -# TODO(PyGMT>=0.19.0): Remove the deprecated 'mode' parameter. # TODO(PyGMT>=0.20.0): Remove the deprecated '*fill' parameters. @deprecate_parameter( "constantfill", "constant_fill", "v0.18.0", remove_version="v0.20.0" @@ -87,7 +75,7 @@ def _validate_params( ) @deprecate_parameter("splinefill", "spline_fill", "v0.18.0", remove_version="v0.20.0") @use_alias(f="coltypes") -def grdfill( # noqa: PLR0913 +def grdfill( grid: PathLike | xr.DataArray, outgrid: PathLike | None = None, constant_fill: float | None = None, @@ -96,7 +84,6 @@ def grdfill( # noqa: PLR0913 spline_fill: float | bool | None = None, inquire: bool = False, hole: float | None = None, - mode: str | None = None, region: Sequence[float | str] | str | None = None, verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | bool = False, @@ -147,16 +134,6 @@ def grdfill( # noqa: PLR0913 Output the bounds of each hole. The bounds are returned as a 2-D numpy array in the form of (west, east, south, north). No grid fill takes place and ``outgrid`` is ignored. - mode - Specify the hole-filling algorithm to use. Choose from **c** for constant fill - and append the constant value, **n** for nearest neighbor (and optionally append - a search radius in pixels [default radius is :math:`r^2 = \sqrt{ X^2 + Y^2 }`, - where (*X,Y*) are the node dimensions of the grid]), or **s** for bicubic spline - (optionally append a *tension* parameter [Default is no tension]). - - .. deprecated:: 0.15.0 - Use ``constant_fill``, ``grid_fill``, ``neighbor_fill``, or ``spline_fill`` - instead. The parameter will be removed in v0.19.0. $region $coltypes @@ -189,13 +166,10 @@ def grdfill( # noqa: PLR0913 [6.16666667, 7.83333333, 0.5 , 2.5 ]]) """ # Validate the fill/inquire parameters. - _validate_params( - constant_fill, grid_fill, neighbor_fill, spline_fill, inquire, mode - ) + _validate_params(constant_fill, grid_fill, neighbor_fill, spline_fill, inquire) # _validate_params has already ensured that only one of the parameters is set. aliasdict = AliasSystem( - A=Alias(mode, name="mode"), Ac=Alias(constant_fill, name="constant_fill"), # For grid_fill, append the actual or virtual grid file name later. Ag=Alias(grid_fill is not None, name="grid_fill"), diff --git a/pygmt/tests/test_grdfill.py b/pygmt/tests/test_grdfill.py index 16788229f86..29a654e38f0 100644 --- a/pygmt/tests/test_grdfill.py +++ b/pygmt/tests/test_grdfill.py @@ -156,13 +156,3 @@ def test_grdfill_inquire_and_fill(grid): """ with pytest.raises(GMTInvalidInput): grdfill(grid=grid, inquire=True, constant_fill=20) - - -# TODO(PyGMT>=0.19.0): Remove this test. -def test_grdfill_deprecated_mode(grid, expected_grid): - """ - Test that grdfill fails with deprecated `mode` argument. - """ - with pytest.warns(FutureWarning): - result = grdfill(grid=grid, mode="c20") - xr.testing.assert_allclose(a=result, b=expected_grid)