Skip to content

Commit 29acaef

Browse files
seismanweiji14
andauthored
Refactor three xfail grdcontour tests (#637)
Refractor three grdcontour tests using the @check_figures_equal decorator so that they no longer xfail. Co-authored-by: Wei Ji <[email protected]>
1 parent 94b23a2 commit 29acaef

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

pygmt/tests/test_grdcontour.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .. import Figure
1010
from ..exceptions import GMTInvalidInput
1111
from ..datasets import load_earth_relief
12+
from ..helpers.testing import check_figures_equal
1213

1314

1415
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
@@ -21,49 +22,49 @@ def fixture_grid():
2122
return load_earth_relief(registration="gridline")
2223

2324

24-
@pytest.mark.xfail(
25-
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
26-
)
27-
@pytest.mark.mpl_image_compare
25+
@check_figures_equal()
2826
def test_grdcontour(grid):
2927
"""Plot a contour image using an xarray grid
3028
with fixed contour interval
3129
"""
32-
fig = Figure()
33-
fig.grdcontour(grid, interval="1000", projection="W0/6i")
34-
return fig
30+
fig_ref, fig_test = Figure(), Figure()
31+
kwargs = dict(interval="1000", projection="W0/6i")
32+
fig_ref.grdcontour("@earth_relief_01d_g", **kwargs)
33+
fig_test.grdcontour(grid, **kwargs)
34+
return fig_ref, fig_test
3535

3636

37-
@pytest.mark.xfail(
38-
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
39-
)
40-
@pytest.mark.mpl_image_compare
37+
@check_figures_equal()
4138
def test_grdcontour_labels(grid):
4239
"""Plot a contour image using a xarray grid
4340
with contour labels and alternate colors
4441
"""
45-
fig = Figure()
46-
fig.grdcontour(
47-
grid,
42+
fig_ref, fig_test = Figure(), Figure()
43+
kwargs = dict(
4844
interval="1000",
4945
annotation="5000",
5046
projection="W0/6i",
5147
pen=["a1p,red", "c0.5p,black"],
5248
label_placement="d3i",
5349
)
54-
return fig
50+
fig_ref.grdcontour("@earth_relief_01d_g", **kwargs)
51+
fig_test.grdcontour(grid, **kwargs)
52+
return fig_ref, fig_test
5553

5654

57-
@pytest.mark.xfail(
58-
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
59-
)
60-
@pytest.mark.mpl_image_compare
55+
@check_figures_equal()
6156
def test_grdcontour_slice(grid):
6257
"Plot an contour image using an xarray grid that has been sliced"
58+
59+
fig_ref, fig_test = Figure(), Figure()
60+
6361
grid_ = grid.sel(lat=slice(-30, 30))
64-
fig = Figure()
65-
fig.grdcontour(grid_, interval="1000", projection="M6i")
66-
return fig
62+
kwargs = dict(interval="1000", projection="M6i")
63+
fig_ref.grdcontour(
64+
grid="@earth_relief_01d_g", region=[-180, 180, -30, 30], **kwargs
65+
)
66+
fig_test.grdcontour(grid=grid_, **kwargs)
67+
return fig_ref, fig_test
6768

6869

6970
@pytest.mark.mpl_image_compare

pygmt/tests/test_grdimage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_grdimage_file():
7171

7272
@pytest.mark.xfail(reason="Upstream bug in GMT 6.1.1")
7373
@check_figures_equal()
74-
def test_grdimage_xarray_shading(grid, fig_ref, fig_test):
74+
def test_grdimage_xarray_shading(grid):
7575
"""
7676
Test that shading works well for xarray.
7777
See https://github.com/GenericMappingTools/pygmt/issues/364

0 commit comments

Comments
 (0)