diff --git a/pygmt/tests/baseline/test_coast.png b/pygmt/tests/baseline/test_coast.png deleted file mode 100644 index 9a31355f638..00000000000 Binary files a/pygmt/tests/baseline/test_coast.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_coast_aliases.png b/pygmt/tests/baseline/test_coast_aliases.png deleted file mode 100644 index 25d33a151cd..00000000000 Binary files a/pygmt/tests/baseline/test_coast_aliases.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_coast_dcw_list.png.dvc b/pygmt/tests/baseline/test_coast_dcw_list.png.dvc new file mode 100644 index 00000000000..28c7e8d07b3 --- /dev/null +++ b/pygmt/tests/baseline/test_coast_dcw_list.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 30c3f4c90ba740b7d9edae97d9d3b853 + size: 93411 + path: test_coast_dcw_list.png diff --git a/pygmt/tests/baseline/test_coast_dcw_single.png.dvc b/pygmt/tests/baseline/test_coast_dcw_single.png.dvc new file mode 100644 index 00000000000..38a0b2b1a5d --- /dev/null +++ b/pygmt/tests/baseline/test_coast_dcw_single.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 40fcf70e1f73ba2be60cbf9e3f15794d + size: 83794 + path: test_coast_dcw_single.png diff --git a/pygmt/tests/baseline/test_coast_iceland.png b/pygmt/tests/baseline/test_coast_iceland.png deleted file mode 100644 index 14a33962956..00000000000 Binary files a/pygmt/tests/baseline/test_coast_iceland.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_coast_region.png.dvc b/pygmt/tests/baseline/test_coast_region.png.dvc new file mode 100644 index 00000000000..1caeef93884 --- /dev/null +++ b/pygmt/tests/baseline/test_coast_region.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 6aecb1529eb8c9535a392f918fc30c38 + size: 82728 + path: test_coast_region.png diff --git a/pygmt/tests/baseline/test_coast_world_mercator.png b/pygmt/tests/baseline/test_coast_world_mercator.png deleted file mode 100644 index 27f9b16fd57..00000000000 Binary files a/pygmt/tests/baseline/test_coast_world_mercator.png and /dev/null differ diff --git a/pygmt/tests/baseline/test_coast_world_mercator.png.dvc b/pygmt/tests/baseline/test_coast_world_mercator.png.dvc new file mode 100644 index 00000000000..7d363abe813 --- /dev/null +++ b/pygmt/tests/baseline/test_coast_world_mercator.png.dvc @@ -0,0 +1,4 @@ +outs: +- md5: 6da57e19a2de4ca60299094139ea6cb0 + size: 119081 + path: test_coast_world_mercator.png diff --git a/pygmt/tests/test_coast.py b/pygmt/tests/test_coast.py index 69635aa30f6..1fc66a0ae9b 100644 --- a/pygmt/tests/test_coast.py +++ b/pygmt/tests/test_coast.py @@ -1,106 +1,33 @@ """ -Tests for coast. +Tests for fig.coast. """ import pytest from pygmt import Figure from pygmt.exceptions import GMTInvalidInput -from pygmt.helpers.testing import check_figures_equal @pytest.mark.mpl_image_compare -def test_coast(): +def test_coast_region(): """ - Simple plot from the GMT docs. + Test plotting a regional map with coastlines. """ fig = Figure() - fig.coast( - R="-30/30/-40/40", - J="m0.1i", - B=5, - I="1/1p,blue", - N="1/0.25p,-", - W="0.25p,white", - G="green", - S="blue", - D="c", - A=10000, - ) + fig.coast(region="JP", projection="M10c", frame=True, land="gray", shorelines=1) return fig -@check_figures_equal() -def test_coast_iceland(): - """ - Test passing in R as a list. - """ - fig_ref, fig_test = Figure(), Figure() - # Use single-character arguments for the reference image - fig_ref.coast(R="-30/-10/60/65", J="m1c", B="", G="p28+r100") - fig_test.coast( - region=[-30, -10, 60, 65], projection="m1c", frame=True, land="p28+r100" - ) - return fig_ref, fig_test - - -@check_figures_equal() -def test_coast_aliases(): - """ - Test that all aliases work. - """ - fig_ref, fig_test = Figure(), Figure() - fig_ref.coast( - R="-30/30/-40/40", - J="M25c", - B="afg", - I="1/1p,black", - N="1/0.5p,-", - W="0.25p,white", - G="moccasin", - S="skyblue", - D="i", - A=1000, - L="jCM+c1+w1000k+f+l", - X="a4c", - Y="a10c", - p="135/25", - t=13, - E="MA+gred", - C="blue", - ) - fig_test.coast( - region=[-30, 30, -40, 40], # R - projection="M25c", # J - frame="afg", # B - rivers="1/1p,black", # I - borders="1/0.5p,-", # N - shorelines="0.25p,white", # W - land="moccasin", # G - water="skyblue", # S - resolution="i", # D - area_thresh=1000, # A - map_scale="jCM+c1+w1000k+f+l", # L - xshift="a4c", # X - yshift="a10c", # Y - perspective=[135, 25], # p - transparency=13, # t - dcw="MA+gred", # E - lakes="blue", # C - ) - return fig_ref, fig_test - - @pytest.mark.mpl_image_compare def test_coast_world_mercator(): """ - Test passing generating a global Mercator map with coastlines. + Test generating a global Mercator map with coastlines. """ fig = Figure() fig.coast( region=[-180, 180, -80, 80], - projection="M10i", + projection="M15c", frame="af", land="#aaaaaa", - resolution="l", + resolution="c", water="white", ) return fig @@ -115,99 +42,33 @@ def test_coast_required_args(): fig.coast(region="EG") -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_coast_dcw_single(): """ Test passing a single country code to dcw. """ - fig_ref, fig_test = Figure(), Figure() - # Use single-character arguments for the reference image - fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="ES+gbisque+pblue") - fig_test.coast( + fig = Figure() + fig.coast( region=[-10, 15, 25, 44], frame="a", projection="M15c", land="brown", dcw="ES+gbisque+pblue", ) - return fig_ref, fig_test - - -@check_figures_equal() -def test_coast_dcw_multiple(): - """ - Test passing multiple country code to dcw. - """ - fig_ref, fig_test = Figure(), Figure() - # Use single-character arguments for the reference image - fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="ES,IT+gbisque+pblue") - fig_test.coast( - region=[-10, 15, 25, 44], - frame="a", - projection="M15c", - land="brown", - dcw="ES,IT+gbisque+pblue", - ) - return fig_ref, fig_test + return fig -@check_figures_equal() +@pytest.mark.mpl_image_compare def test_coast_dcw_list(): """ Test passing a list of country codes and fill options to dcw. """ - fig_ref, fig_test = Figure(), Figure() - # Use single-character arguments for the reference image - fig_ref.coast( - R="-10/15/25/44", - J="M15c", - B="a", - G="brown", - E=["ES+gbisque+pgreen", "IT+gcyan+pblue"], - ) - fig_test.coast( + fig = Figure() + fig.coast( region=[-10, 15, 25, 44], frame="a", projection="M15c", land="brown", dcw=["ES+gbisque+pgreen", "IT+gcyan+pblue"], ) - return fig_ref, fig_test - - -@check_figures_equal() -def test_coast_dcw_continent(): - """ - Test passing a continent code to dcw. - """ - fig_ref, fig_test = Figure(), Figure() - # Use single-character arguments for the reference image - fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="=AF+gbisque+pblue") - fig_test.coast( - region=[-10, 15, 25, 44], - frame="a", - projection="M15c", - land="brown", - dcw="=AF+gbisque+pblue", - ) - return fig_ref, fig_test - - -@check_figures_equal() -def test_coast_dcw_state(): - """ - Test passing a US state code to dcw. - """ - fig_ref, fig_test = Figure(), Figure() - # Use single-character arguments for the reference image - fig_ref.coast( - R="-75/-69/40/44", J="M15c", B="a", G="brown", E="US.MA+gbisque+pblue" - ) - fig_test.coast( - region=[-75, -69, 40, 44], - frame="a", - projection="M15c", - land="brown", - dcw="US.MA+gbisque+pblue", - ) - return fig_ref, fig_test + return fig