Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Figure.coast tests to dvc #1103

Merged
merged 29 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
faa064d
update tests to use mpl_image_compare
willschlitzer Mar 22, 2021
0920817
remove old reference images
willschlitzer Mar 22, 2021
5d1fdce
add dvc files for test_coast.py
willschlitzer Mar 22, 2021
fdac609
remove unused import from test_coast.py
willschlitzer Mar 22, 2021
9e80bba
Merge branch 'master' into test-coast-dvc
willschlitzer Mar 23, 2021
2b6c263
Merge branch 'master' into test-coast-dvc
willschlitzer Mar 23, 2021
eba3e9e
Update pygmt/tests/test_coast.py
willschlitzer Mar 23, 2021
2f7ba86
Update test_coast_aliases() in test_coast.py
willschlitzer Mar 23, 2021
6f28b01
Update test_coast_aliases() in test_coast.py
willschlitzer Mar 23, 2021
0fcbdfc
Update test_coast_aliases.png.dvc
willschlitzer Mar 23, 2021
28640f0
remove test_coast() from test_coast.py; tests a subset of arguments/p…
willschlitzer Mar 23, 2021
2c27ee7
Merge branch 'master' into test-coast-dvc
willschlitzer Mar 23, 2021
7c25db1
Merge branch 'master' into test-coast-dvc
willschlitzer Mar 23, 2021
b90f6b6
Merge branch 'master' into test-coast-dvc
willschlitzer Mar 27, 2021
ab49fa1
remove test_coast_aliases()
willschlitzer Mar 27, 2021
745cdda
remove test_coast_dcw_multiple()
willschlitzer Mar 27, 2021
a869c78
remove test_coast_dcw_state()
willschlitzer Mar 27, 2021
ec0f26d
remove test_coast_dcw_continent()
willschlitzer Mar 27, 2021
264831f
run make format
willschlitzer Mar 27, 2021
831e43f
remove unused .dvc files
willschlitzer Mar 27, 2021
5a77338
Apply suggestions from code review
willschlitzer Mar 28, 2021
cf99b6d
update docstring in test_coast_world_mercator()
willschlitzer Mar 28, 2021
9ad494e
update projection resolution and size in test_coast_world_mercator
willschlitzer Mar 28, 2021
150c45e
change test_coast_iceland() to test_coast_region()
willschlitzer Mar 28, 2021
30fe194
update .dvc files for test_coast_world_mercator.png.dvc and test_coas…
willschlitzer Mar 28, 2021
edb5d4b
Merge branch 'master' into test-coast-dvc
willschlitzer Mar 28, 2021
bd3fc84
Merge branch 'master' into test-coast-dvc
willschlitzer Mar 30, 2021
0a1c5e7
remove test_coast_iceland.png.dvc
willschlitzer Mar 30, 2021
82cd7f0
Merge remote-tracking branch 'origin/test-coast-dvc' into test-coast-dvc
willschlitzer Mar 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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():
seisman marked this conversation as resolved.
Show resolved Hide resolved
"""
seisman marked this conversation as resolved.
Show resolved Hide resolved
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