Skip to content

Commit

Permalink
Refactor three xfail grdcontour tests (#637)
Browse files Browse the repository at this point in the history
Refractor three grdcontour tests using the @check_figures_equal decorator so that they no longer xfail.

Co-authored-by: Wei Ji <[email protected]>
  • Loading branch information
seisman and weiji14 authored Sep 30, 2020
1 parent 94b23a2 commit 29acaef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 23 additions & 22 deletions pygmt/tests/test_grdcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .. import Figure
from ..exceptions import GMTInvalidInput
from ..datasets import load_earth_relief
from ..helpers.testing import check_figures_equal


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


@pytest.mark.xfail(
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
)
@pytest.mark.mpl_image_compare
@check_figures_equal()
def test_grdcontour(grid):
"""Plot a contour image using an xarray grid
with fixed contour interval
"""
fig = Figure()
fig.grdcontour(grid, interval="1000", projection="W0/6i")
return fig
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(interval="1000", projection="W0/6i")
fig_ref.grdcontour("@earth_relief_01d_g", **kwargs)
fig_test.grdcontour(grid, **kwargs)
return fig_ref, fig_test


@pytest.mark.xfail(
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
)
@pytest.mark.mpl_image_compare
@check_figures_equal()
def test_grdcontour_labels(grid):
"""Plot a contour image using a xarray grid
with contour labels and alternate colors
"""
fig = Figure()
fig.grdcontour(
grid,
fig_ref, fig_test = Figure(), Figure()
kwargs = dict(
interval="1000",
annotation="5000",
projection="W0/6i",
pen=["a1p,red", "c0.5p,black"],
label_placement="d3i",
)
return fig
fig_ref.grdcontour("@earth_relief_01d_g", **kwargs)
fig_test.grdcontour(grid, **kwargs)
return fig_ref, fig_test


@pytest.mark.xfail(
reason="Baseline image not updated to use earth relief grid in GMT 6.1.0",
)
@pytest.mark.mpl_image_compare
@check_figures_equal()
def test_grdcontour_slice(grid):
"Plot an contour image using an xarray grid that has been sliced"

fig_ref, fig_test = Figure(), Figure()

grid_ = grid.sel(lat=slice(-30, 30))
fig = Figure()
fig.grdcontour(grid_, interval="1000", projection="M6i")
return fig
kwargs = dict(interval="1000", projection="M6i")
fig_ref.grdcontour(
grid="@earth_relief_01d_g", region=[-180, 180, -30, 30], **kwargs
)
fig_test.grdcontour(grid=grid_, **kwargs)
return fig_ref, fig_test


@pytest.mark.mpl_image_compare
Expand Down
2 changes: 1 addition & 1 deletion pygmt/tests/test_grdimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_grdimage_file():

@pytest.mark.xfail(reason="Upstream bug in GMT 6.1.1")
@check_figures_equal()
def test_grdimage_xarray_shading(grid, fig_ref, fig_test):
def test_grdimage_xarray_shading(grid):
"""
Test that shading works well for xarray.
See https://github.com/GenericMappingTools/pygmt/issues/364
Expand Down

0 comments on commit 29acaef

Please sign in to comment.