Skip to content

Commit e90b987

Browse files
authored
Fix failing tests for legacy GMT versions (#3021)
1 parent 39950f8 commit e90b987

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

pygmt/tests/test_datasets_earth_relief.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import numpy as np
55
import numpy.testing as npt
66
import pytest
7+
from packaging.version import Version
8+
from pygmt.clib import __gmt_version__
79
from pygmt.datasets import load_earth_relief
810
from pygmt.exceptions import GMTInvalidInput
911

@@ -186,6 +188,10 @@ def test_earth_relief_15s_default_registration():
186188
npt.assert_allclose(data.max(), -71, atol=0.5)
187189

188190

191+
@pytest.mark.xfail(
192+
condition=Version(__gmt_version__) >= Version("6.5.0"),
193+
reason="Upstream bug tracked in https://github.com/GenericMappingTools/pygmt/issues/2511",
194+
)
189195
def test_earth_relief_03s_default_registration():
190196
"""
191197
Test that the grid returned by default for the 3 arc-second resolution has a
@@ -198,5 +204,5 @@ def test_earth_relief_03s_default_registration():
198204
npt.assert_allclose(data.coords["lat"].data.max(), 5)
199205
npt.assert_allclose(data.coords["lon"].data.min(), -10)
200206
npt.assert_allclose(data.coords["lon"].data.max(), -9.8)
201-
npt.assert_allclose(data.min(), -2131.9, atol=0.5)
207+
npt.assert_allclose(data.min(), -2069.85, atol=0.5)
202208
npt.assert_allclose(data.max(), -924.5, atol=0.5)

pygmt/tests/test_datasets_load_remote_datasets.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Test the _load_remote_dataset function.
33
"""
44
import pytest
5+
from packaging.version import Version
6+
from pygmt.clib import __gmt_version__
57
from pygmt.datasets.load_remote_dataset import _load_remote_dataset
68
from pygmt.exceptions import GMTInvalidInput
79

@@ -27,11 +29,13 @@ def test_load_remote_dataset_benchmark_with_region():
2729
data = load_remote_dataset_wrapper(resolution="01d", region=[-10, 10, -5, 5])
2830
assert data.name == "seafloor_age"
2931
assert data.attrs["long_name"] == "age of seafloor crust"
30-
assert data.attrs["cpt"] == "@earth_age.cpt"
3132
assert data.attrs["units"] == "Myr"
3233
assert data.attrs["horizontal_datum"] == "WGS84"
3334
assert data.gmt.registration == 0
3435
assert data.shape == (11, 21)
36+
# The cpt attribute was added since GMT 6.4.0
37+
if Version(__gmt_version__) >= Version("6.4.0"):
38+
assert data.attrs["cpt"] == "@earth_age.cpt"
3539

3640

3741
def test_load_remote_dataset_invalid_resolutions():

pygmt/tests/test_x2sys_cross.py

+14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import numpy.testing as npt
1111
import pandas as pd
1212
import pytest
13+
from packaging.version import Version
1314
from pygmt import x2sys_cross, x2sys_init
15+
from pygmt.clib import __gmt_version__
1416
from pygmt.datasets import load_sample_data
1517
from pygmt.exceptions import GMTInvalidInput
1618
from pygmt.helpers import data_kind
@@ -55,6 +57,10 @@ def test_x2sys_cross_input_file_output_file():
5557

5658

5759
@pytest.mark.usefixtures("mock_x2sys_home")
60+
@pytest.mark.xfail(
61+
condition=Version(__gmt_version__) < Version("6.5.0"),
62+
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
63+
)
5864
def test_x2sys_cross_input_file_output_dataframe():
5965
"""
6066
Run x2sys_cross by passing in a filename, and output internal crossovers to a
@@ -196,6 +202,10 @@ def test_x2sys_cross_invalid_tracks_input_type(tracks):
196202

197203

198204
@pytest.mark.usefixtures("mock_x2sys_home")
205+
@pytest.mark.xfail(
206+
condition=Version(__gmt_version__) < Version("6.5.0"),
207+
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
208+
)
199209
def test_x2sys_cross_region_interpolation_numpoints():
200210
"""
201211
Test that x2sys_cross's region (R), interpolation (l) and numpoints (W) arguments
@@ -221,6 +231,10 @@ def test_x2sys_cross_region_interpolation_numpoints():
221231

222232

223233
@pytest.mark.usefixtures("mock_x2sys_home")
234+
@pytest.mark.xfail(
235+
condition=Version(__gmt_version__) < Version("6.5.0"),
236+
reason="Upstream bug fixed in https://github.com/GenericMappingTools/gmt/pull/8188",
237+
)
224238
def test_x2sys_cross_trackvalues():
225239
"""
226240
Test that x2sys_cross's trackvalues (Z) argument work.

0 commit comments

Comments
 (0)