Skip to content

Commit

Permalink
Migrate Figure.coast tests to dvc (#1103)
Browse files Browse the repository at this point in the history
Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Dongdong Tian <[email protected]>
  • Loading branch information
3 people committed Mar 30, 2021
1 parent 7700ea1 commit c280711
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 154 deletions.
Binary file removed pygmt/tests/baseline/test_coast.png
Binary file not shown.
Binary file removed pygmt/tests/baseline/test_coast_aliases.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_dcw_list.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 30c3f4c90ba740b7d9edae97d9d3b853
size: 93411
path: test_coast_dcw_list.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_dcw_single.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 40fcf70e1f73ba2be60cbf9e3f15794d
size: 83794
path: test_coast_dcw_single.png
Binary file removed pygmt/tests/baseline/test_coast_iceland.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_region.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 6aecb1529eb8c9535a392f918fc30c38
size: 82728
path: test_coast_region.png
Binary file removed pygmt/tests/baseline/test_coast_world_mercator.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_coast_world_mercator.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 6da57e19a2de4ca60299094139ea6cb0
size: 119081
path: test_coast_world_mercator.png
169 changes: 15 additions & 154 deletions pygmt/tests/test_coast.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit c280711

Please sign in to comment.