Skip to content

Commit 077a9a7

Browse files
authored
pygmt.grdtrack: Remove the warning about the incorrect parameter order of 'points, grid' (warned since v0.7.0) (#2312)
1 parent c14067d commit 077a9a7

File tree

2 files changed

+0
-42
lines changed

2 files changed

+0
-42
lines changed

pygmt/src/grdtrack.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""
22
grdtrack - Sample grids at specified (x,y) locations.
33
"""
4-
import warnings
5-
64
import pandas as pd
7-
import xarray as xr
85
from pygmt.clib import Session
96
from pygmt.exceptions import GMTInvalidInput
107
from pygmt.helpers import (
@@ -14,7 +11,6 @@
1411
kwargs_to_strings,
1512
use_alias,
1613
)
17-
from pygmt.src.which import which
1814

1915
__doctest_skip__ = ["grdtrack"]
2016

@@ -297,29 +293,6 @@ def grdtrack(grid, points=None, newcolname=None, outfile=None, **kwargs):
297293
if hasattr(points, "columns") and newcolname is None:
298294
raise GMTInvalidInput("Please pass in a str to 'newcolname'")
299295

300-
# Backward compatibility with old parameter order "points, grid".
301-
# deprecated_version="0.7.0", remove_version="v0.9.0"
302-
is_a_grid = True
303-
if not isinstance(grid, (xr.DataArray, str)):
304-
is_a_grid = False
305-
elif isinstance(grid, str):
306-
try:
307-
xr.open_dataarray(which(grid, download="a"), engine="netcdf4").close()
308-
is_a_grid = True
309-
except (ValueError, OSError):
310-
is_a_grid = False
311-
if not is_a_grid:
312-
msg = (
313-
"Positional parameters 'points, grid' of pygmt.grdtrack() has changed "
314-
"to 'grid, points=None' since v0.7.0. It's likely that you're NOT "
315-
"passing a valid grid as the first positional argument or "
316-
"are passing an invalid grid to the 'grid' parameter. "
317-
"Please check the order of arguments with the latest documentation. "
318-
"This warning will be removed in v0.9.0."
319-
)
320-
grid, points = points, grid
321-
warnings.warn(msg, category=FutureWarning, stacklevel=1)
322-
323296
with GMTTempFile(suffix=".csv") as tmpfile:
324297
with Session() as lib:
325298
# Store the xarray.DataArray grid in virtualfile

pygmt/tests/test_grdtrack.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,3 @@ def test_grdtrack_set_points_and_profile(dataarray, dataframe):
177177
"""
178178
with pytest.raises(GMTInvalidInput):
179179
grdtrack(grid=dataarray, points=dataframe, profile="BL/TR")
180-
181-
182-
def test_grdtrack_old_parameter_order(dataframe, dataarray, expected_array):
183-
"""
184-
Run grdtrack with the old parameter order 'points, grid'.
185-
186-
This test should be removed in v0.9.0.
187-
"""
188-
for points in (POINTS_DATA, dataframe):
189-
for grid in ("@static_earth_relief.nc", dataarray):
190-
with pytest.warns(expected_warning=FutureWarning) as record:
191-
output = grdtrack(points, grid)
192-
assert len(record) == 1
193-
assert isinstance(output, pd.DataFrame)
194-
npt.assert_allclose(np.array(output), expected_array)

0 commit comments

Comments
 (0)