Skip to content

Commit 4b80f3c

Browse files
weiji14Meghan Jones
and
Meghan Jones
authored
Mark two grdtrack tests as xfail due to upstream GMT 6.3 fixes (#1608)
Using correct output values for `grdtrack` with bicubic interpolation for `xarray.DataArray` grids on GMT 6.3. Co-authored-by: Meghan Jones <[email protected]>
1 parent 5dc135b commit 4b80f3c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

pygmt/tests/test_grdtrack.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
import numpy.testing as npt
77
import pandas as pd
88
import pytest
9-
from pygmt import grdtrack, which
9+
from packaging.version import Version
10+
from pygmt import clib, grdtrack, which
1011
from pygmt.datasets import load_earth_relief, load_ocean_ridge_points
1112
from pygmt.exceptions import GMTInvalidInput
1213
from pygmt.helpers import data_kind
1314

1415
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
1516
TEMP_TRACK = os.path.join(TEST_DATA_DIR, "tmp_track.txt")
1617

18+
with clib.Session() as _lib:
19+
gmt_version = Version(_lib.info["version"])
20+
1721

1822
@pytest.fixture(scope="module", name="dataarray")
1923
def fixture_dataarray():
@@ -49,6 +53,10 @@ def fixture_ncfile():
4953
return which("@earth_relief_01d", download="a")
5054

5155

56+
@pytest.mark.xfail(
57+
condition=gmt_version <= Version("6.2.0"),
58+
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/5893.",
59+
)
5260
def test_grdtrack_input_dataframe_and_dataarray(dataarray, dataframe):
5361
"""
5462
Run grdtrack by passing in a pandas.DataFrame and xarray.DataArray as
@@ -57,11 +65,15 @@ def test_grdtrack_input_dataframe_and_dataarray(dataarray, dataframe):
5765
output = grdtrack(points=dataframe, grid=dataarray, newcolname="bathymetry")
5866
assert isinstance(output, pd.DataFrame)
5967
assert output.columns.to_list() == ["longitude", "latitude", "bathymetry"]
60-
npt.assert_allclose(output.iloc[0], [-110.9536, -42.2489, -2790.488422])
68+
npt.assert_allclose(output.iloc[0], [-110.9536, -42.2489, -2797.394987])
6169

6270
return output
6371

6472

73+
@pytest.mark.xfail(
74+
condition=gmt_version <= Version("6.2.0"),
75+
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/5893.",
76+
)
6577
def test_grdtrack_input_csvfile_and_dataarray(dataarray, csvfile):
6678
"""
6779
Run grdtrack by passing in a csvfile and xarray.DataArray as inputs.
@@ -72,7 +84,7 @@ def test_grdtrack_input_csvfile_and_dataarray(dataarray, csvfile):
7284
assert os.path.exists(path=TEMP_TRACK) # check that outfile exists at path
7385

7486
track = pd.read_csv(TEMP_TRACK, sep="\t", header=None, comment=">")
75-
npt.assert_allclose(track.iloc[0], [-110.9536, -42.2489, -2790.488422])
87+
npt.assert_allclose(track.iloc[0], [-110.9536, -42.2489, -2797.394987])
7688
finally:
7789
os.remove(path=TEMP_TRACK)
7890

0 commit comments

Comments
 (0)