Skip to content

Commit 43f765f

Browse files
Deprecate splinefill/constantfill/neighborfill/gridfill to spline_fill/constant_fill/neighbor_fill/grid_fill
1 parent e8cd1e3 commit 43f765f

1 file changed

Lines changed: 36 additions & 31 deletions

File tree

pygmt/src/grdfill.py

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@
1818

1919

2020
def _validate_params(
21-
constantfill=None,
22-
gridfill=None,
23-
neighborfill=None,
24-
splinefill=None,
21+
constant_fill=None,
22+
grid_fill=None,
23+
neighbor_fill=None,
24+
spline_fill=None,
2525
inquire=False,
2626
mode=None,
2727
):
2828
"""
2929
Validate the fill/inquire parameters.
3030
31-
>>> _validate_params(constantfill=20.0)
31+
>>> _validate_params(constant_fill=20.0)
3232
>>> _validate_params(inquire=True)
3333
>>> _validate_params(mode="c20.0")
34-
>>> _validate_params(constantfill=20.0, gridfill="bggrid.nc")
34+
>>> _validate_params(constant_fill=20.0, grid_fill="bggrid.nc")
3535
Traceback (most recent call last):
3636
...
3737
pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive.
38-
>>> _validate_params(constantfill=20.0, inquire=True)
38+
>>> _validate_params(constant_fill=20.0, inquire=True)
3939
Traceback (most recent call last):
4040
...
4141
pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive.
@@ -44,7 +44,7 @@ def _validate_params(
4444
...
4545
pygmt.exceptions.GMTInvalidInput: Need to specify parameter ...
4646
"""
47-
_fill_params = "'constantfill'/'gridfill'/'neighborfill'/'splinefill'"
47+
_fill_params = "'constant_fill'/'grid_fill'/'neighbor_fill'/'spline_fill'"
4848
# The deprecated 'mode' parameter is given.
4949
if mode is not None:
5050
msg = (
@@ -55,7 +55,7 @@ def _validate_params(
5555

5656
n_given = sum(
5757
param is not None and param is not False
58-
for param in [constantfill, gridfill, neighborfill, splinefill, inquire, mode]
58+
for param in [constant_fill, grid_fill, neighbor_fill, spline_fill, inquire, mode]
5959
)
6060
if n_given > 1: # More than one mutually exclusive parameter is given.
6161
msg = f"Parameters {_fill_params}/'inquire'/'mode' are mutually exclusive."
@@ -71,15 +71,19 @@ def _validate_params(
7171
@fmt_docstring
7272
# TODO(PyGMT>=0.19.0): Remove the deprecated 'no_data' parameter.
7373
# TODO(PyGMT>=0.19.0): Remove the deprecated 'mode' parameter.
74-
@deprecate_parameter("no_data", "hole", "v0.15.0", remove_version="v0.19.0")
74+
@deprecate_parameter("no_data", "hole", "v0.18.0", remove_version="v0.20.0")
75+
@deprecate_parameter("constantfill", "constant_fill", "v0.15.0", remove_version="v0.19.0")
76+
@deprecate_parameter("gridfill", "grid_fill", "v0.18.0", remove_version="v0.20.0")
77+
@deprecate_parameter("neighborfill", "neighbor_fill", "v0.18.0", remove_version="v0.20.0")
78+
@deprecate_parameter("splinefill", "spline_fill", "v0.18.0", remove_version="v0.20.0")
7579
@use_alias(f="coltypes")
7680
def grdfill( # noqa: PLR0913
7781
grid: PathLike | xr.DataArray,
7882
outgrid: PathLike | None = None,
79-
constantfill: float | None = None,
80-
gridfill: PathLike | xr.DataArray | None = None,
81-
neighborfill: float | bool | None = None,
82-
splinefill: float | bool | None = None,
83+
constant_fill: float | None = None,
84+
grid_fill: PathLike | xr.DataArray | None = None,
85+
neighbor_fill: float | bool | None = None,
86+
spline_fill: float | bool | None = None,
8387
inquire: bool = False,
8488
hole: float | None = None,
8589
mode: str | None = None,
@@ -100,10 +104,10 @@ def grdfill( # noqa: PLR0913
100104
Full GMT docs at :gmt-docs:`grdfill.html`.
101105
102106
$aliases
103-
- Ac = constantfill
104-
- Ag = gridfill
105-
- An = neighborfill
106-
- As = splinefill
107+
- Ac = constant_fill
108+
- Ag = grid_fill
109+
- An = neighbor_fill
110+
- As = spline_fill
107111
- L = inquire
108112
- N = hole
109113
- R = region
@@ -113,17 +117,17 @@ def grdfill( # noqa: PLR0913
113117
----------
114118
$grid
115119
$outgrid
116-
constantfill
120+
constant_fill
117121
Fill the holes with a constant value. Specify the constant value to use.
118-
gridfill
122+
grid_fill
119123
Fill the holes with values sampled from another (possibly coarser) grid. Specify
120124
the grid (a file name or an :class:`xarray.DataArray`) to use for the fill.
121-
neighborfill
125+
neighbor_fill
122126
Fill the holes with the nearest neighbor. Specify the search radius in pixels.
123127
If set to ``True``, the default search radius will be used
124128
(:math:`r^2 = \sqrt{n^2 + m^2}`, where (*n,m*) are the node dimensions of the
125129
grid).
126-
splinefill
130+
spline_fill
127131
Fill the holes with a bicubic spline. Specify the tension value to use. If set
128132
to ``True``, no tension will be used.
129133
hole
@@ -141,8 +145,9 @@ def grdfill( # noqa: PLR0913
141145
(optionally append a *tension* parameter [Default is no tension]).
142146
143147
.. deprecated:: 0.15.0
144-
Use ``constantfill``, ``gridfill``, ``neighborfill``, or ``splinefill``
148+
Use ``constant_fill``, ``grid_fill``, ``neighbor_fill``, or ``spline_fill``
145149
instead. The parameter will be removed in v0.19.0.
150+
146151
$region
147152
$coltypes
148153
$verbose
@@ -165,7 +170,7 @@ def grdfill( # noqa: PLR0913
165170
>>> # Load a bathymetric grid with missing data
166171
>>> earth_relief_holes = pygmt.datasets.load_sample_data(name="earth_relief_holes")
167172
>>> # Fill the holes with a constant value of 20
168-
>>> filled_grid = pygmt.grdfill(grid=earth_relief_holes, constantfill=20)
173+
>>> filled_grid = pygmt.grdfill(grid=earth_relief_holes, constant_fill=20)
169174
170175
Inquire the bounds of each hole.
171176
@@ -174,16 +179,16 @@ def grdfill( # noqa: PLR0913
174179
[6.16666667, 7.83333333, 0.5 , 2.5 ]])
175180
"""
176181
# Validate the fill/inquire parameters.
177-
_validate_params(constantfill, gridfill, neighborfill, splinefill, inquire, mode)
182+
_validate_params(constant_fill, grid_fill, neighbor_fill, spline_fill, inquire, mode)
178183

179184
# _validate_params has already ensured that only one of the parameters is set.
180185
aliasdict = AliasSystem(
181186
A=Alias(mode, name="mode"),
182-
Ac=Alias(constantfill, name="constantfill"),
183-
# For grdfill, append the actual or virtual grid file name later.
184-
Ag=Alias(gridfill is not None, name="gridfill"),
185-
An=Alias(neighborfill, name="neighborfill"),
186-
As=Alias(splinefill, name="splinefill"),
187+
Ac=Alias(constant_fill, name="constant_fill"),
188+
# For grifill, append the actual or virtual grid file name later.
189+
Ag=Alias(grid_fill is not None, name="grid_fill"),
190+
An=Alias(neighbor_fill, name="neighbor_fill"),
191+
As=Alias(spline_fill, name="spline_fill"),
187192
L=Alias(inquire, name="inquire"),
188193
N=Alias(hole, name="hole"),
189194
).add_common(
@@ -207,7 +212,7 @@ def grdfill( # noqa: PLR0913
207212
# Fill mode.
208213
with (
209214
lib.virtualfile_in(
210-
check_kind="raster", data=gridfill, required=False
215+
check_kind="raster", data=grid_fill, required=False
211216
) as vbggrd,
212217
lib.virtualfile_out(kind="grid", fname=outgrid) as voutgrd,
213218
):

0 commit comments

Comments
 (0)