diff --git a/pygmt/tests/baseline/test_grdcontour.png b/pygmt/tests/baseline/test_grdcontour.png deleted file mode 100644 index f48340f9b91..00000000000 Binary files a/pygmt/tests/baseline/test_grdcontour.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_grdcontour.png.dvc b/pygmt/tests/baseline/test_grdcontour.png.dvc new file mode 100644 index 00000000000..ec4d73fcf13 --- /dev/null +++ b/pygmt/tests/baseline/test_grdcontour.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 438f13a0356e3bec8e3762180ea9c2f0 + size: 219869 + path: test_grdcontour.png diff --git a/pygmt/tests/baseline/test_grdcontour_file.png b/pygmt/tests/baseline/test_grdcontour_file.png deleted file mode 100644 index 444f1d1eba0..00000000000 Binary files a/pygmt/tests/baseline/test_grdcontour_file.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_grdcontour_file.png.dvc b/pygmt/tests/baseline/test_grdcontour_file.png.dvc new file mode 100644 index 00000000000..67d535947a1 --- /dev/null +++ b/pygmt/tests/baseline/test_grdcontour_file.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: fa2f0be00003b6a1cf8cc80da0eb824c + size: 102192 + path: test_grdcontour_file.png diff --git a/pygmt/tests/baseline/test_grdcontour_interval_file_full_opts.png b/pygmt/tests/baseline/test_grdcontour_interval_file_full_opts.png deleted file mode 100644 index 41bb07b6e21..00000000000 Binary files a/pygmt/tests/baseline/test_grdcontour_interval_file_full_opts.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_grdcontour_interval_file_full_opts.png.dvc b/pygmt/tests/baseline/test_grdcontour_interval_file_full_opts.png.dvc new file mode 100644 index 00000000000..ee658bca1d6 --- /dev/null +++ b/pygmt/tests/baseline/test_grdcontour_interval_file_full_opts.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 7f655c17e068dd4860c5f97b7503a314 + size: 38237 + path: test_grdcontour_interval_file_full_opts.png diff --git a/pygmt/tests/baseline/test_grdcontour_labels.png b/pygmt/tests/baseline/test_grdcontour_labels.png deleted file mode 100644 index 7a0c9557ff4..00000000000 Binary files a/pygmt/tests/baseline/test_grdcontour_labels.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_grdcontour_labels.png.dvc b/pygmt/tests/baseline/test_grdcontour_labels.png.dvc new file mode 100644 index 00000000000..e805c4ab3b6 --- /dev/null +++ b/pygmt/tests/baseline/test_grdcontour_labels.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 582303f039a43f271c543b78d3a3ff4b + size: 226135 + path: test_grdcontour_labels.png diff --git a/pygmt/tests/baseline/test_grdcontour_slice.png b/pygmt/tests/baseline/test_grdcontour_slice.png deleted file mode 100644 index 427ce5a5f1f..00000000000 Binary files a/pygmt/tests/baseline/test_grdcontour_slice.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_grdcontour_slice.png.dvc b/pygmt/tests/baseline/test_grdcontour_slice.png.dvc new file mode 100644 index 00000000000..c83a179e874 --- /dev/null +++ b/pygmt/tests/baseline/test_grdcontour_slice.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: c9538960aae7cd5263bce0f6bda20090 + size: 102143 + path: test_grdcontour_slice.png diff --git a/pygmt/tests/test_grdcontour.py b/pygmt/tests/test_grdcontour.py index b208be55d6e..2c759afcca6 100644 --- a/pygmt/tests/test_grdcontour.py +++ b/pygmt/tests/test_grdcontour.py @@ -8,7 +8,6 @@ from pygmt import Figure from pygmt.datasets import load_earth_relief from pygmt.exceptions import GMTInvalidInput -from pygmt.helpers.testing import check_figures_equal TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data") TEST_CONTOUR_FILE = os.path.join(TEST_DATA_DIR, "contours.txt") @@ -22,52 +21,45 @@ def fixture_grid(): return load_earth_relief(registration="gridline") -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_grdcontour(grid): """ Plot a contour image using an xarray grid with fixed contour interval. """ - 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 + fig = Figure() + fig.grdcontour(grid, interval="1000", projection="W0/15c", frame=True) + return fig -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_grdcontour_labels(grid): """ Plot a contour image using a xarray grid with contour labels and alternate colors. """ - fig_ref, fig_test = Figure(), Figure() - kwargs = dict( + fig = Figure() + fig.grdcontour( + grid, interval="1000", annotation="5000", - projection="W0/6i", + projection="W0/15c", pen=["a1p,red", "c0.5p,black"], - label_placement="d3i", + label_placement="d6c", + frame=True, ) - fig_ref.grdcontour("@earth_relief_01d_g", **kwargs) - fig_test.grdcontour(grid, **kwargs) - return fig_ref, fig_test + return fig -@check_figures_equal() +@pytest.mark.mpl_image_compare 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)) - 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 + + fig = Figure() + fig.grdcontour(grid=grid_, interval="1000", projection="M15c", frame=True) + return fig @pytest.mark.mpl_image_compare @@ -82,43 +74,31 @@ def test_grdcontour_file(): limit="0", pen="0.5p,black", region=[-180, 180, -70, 70], - projection="M10i", + projection="M15c", + frame=True, ) return fig -@check_figures_equal() -def test_grdcontour_interval_file_full_opts(): +@pytest.mark.mpl_image_compare +def test_grdcontour_interval_file_full_opts(grid): """ Plot based on external contour level file. """ - fig_ref, fig_test = Figure(), Figure() - # Use single-character arguments for the reference image - comargs_ref = { - "grid": "@earth_relief_10m", - "R": "-161.5/-154/18.5/23", - "C": TEST_CONTOUR_FILE, - "S": 100, - "J": "M6i", - "Q": 10, - } - fig_ref.grdcontour(**comargs_ref, L="-25000/-1", W=["a1p,blue", "c0.5p,blue"]) - fig_ref.grdcontour(**comargs_ref, L="0", W=["a1p,black", "c0.5p,black"]) + fig = Figure() - comargs_test = { + comargs = { "region": [-161.5, -154, 18.5, 23], "interval": TEST_CONTOUR_FILE, - "grid": "@earth_relief_10m", + "grid": grid, "resample": "100", - "projection": "M6i", + "projection": "M10c", "cut": 10, } - fig_test.grdcontour( - **comargs_test, limit=(-25000, -1), pen=["a1p,blue", "c0.5p,blue"] - ) - fig_test.grdcontour(**comargs_test, limit=0, pen=["a1p,black", "c0.5p,black"]) + fig.grdcontour(**comargs, limit=(-25000, -1), pen=["a1p,blue", "c0.5p,blue"]) + fig.grdcontour(**comargs, limit=0, pen=["a1p,black", "c0.5p,black"], frame=True) - return fig_ref, fig_test + return fig def test_grdcontour_fails():