Skip to content

Commit

Permalink
Mark two grdtrack tests as xfail due to upstream GMT 6.3 fixes (#1608)
Browse files Browse the repository at this point in the history
Using correct output values for `grdtrack` with bicubic
interpolation for `xarray.DataArray` grids on GMT 6.3.

Co-authored-by: Meghan Jones <[email protected]>
  • Loading branch information
weiji14 and maxrjones authored Nov 5, 2021
1 parent 5dc135b commit 4b80f3c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pygmt/tests/test_grdtrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
import numpy.testing as npt
import pandas as pd
import pytest
from pygmt import grdtrack, which
from packaging.version import Version
from pygmt import clib, grdtrack, which
from pygmt.datasets import load_earth_relief, load_ocean_ridge_points
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import data_kind

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

with clib.Session() as _lib:
gmt_version = Version(_lib.info["version"])


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


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

return output


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

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

Expand Down

0 comments on commit 4b80f3c

Please sign in to comment.