Skip to content

Commit c280711

Browse files
willschlitzerweiji14seisman
authored
Migrate Figure.coast tests to dvc (#1103)
Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
1 parent 7700ea1 commit c280711

9 files changed

+31
-154
lines changed

pygmt/tests/baseline/test_coast.png

-133 KB
Binary file not shown.
-184 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 30c3f4c90ba740b7d9edae97d9d3b853
3+
size: 93411
4+
path: test_coast_dcw_list.png
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 40fcf70e1f73ba2be60cbf9e3f15794d
3+
size: 83794
4+
path: test_coast_dcw_single.png
-23.3 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 6aecb1529eb8c9535a392f918fc30c38
3+
size: 82728
4+
path: test_coast_region.png
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 6da57e19a2de4ca60299094139ea6cb0
3+
size: 119081
4+
path: test_coast_world_mercator.png

pygmt/tests/test_coast.py

Lines changed: 15 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,33 @@
11
"""
2-
Tests for coast.
2+
Tests for fig.coast.
33
"""
44
import pytest
55
from pygmt import Figure
66
from pygmt.exceptions import GMTInvalidInput
7-
from pygmt.helpers.testing import check_figures_equal
87

98

109
@pytest.mark.mpl_image_compare
11-
def test_coast():
10+
def test_coast_region():
1211
"""
13-
Simple plot from the GMT docs.
12+
Test plotting a regional map with coastlines.
1413
"""
1514
fig = Figure()
16-
fig.coast(
17-
R="-30/30/-40/40",
18-
J="m0.1i",
19-
B=5,
20-
I="1/1p,blue",
21-
N="1/0.25p,-",
22-
W="0.25p,white",
23-
G="green",
24-
S="blue",
25-
D="c",
26-
A=10000,
27-
)
15+
fig.coast(region="JP", projection="M10c", frame=True, land="gray", shorelines=1)
2816
return fig
2917

3018

31-
@check_figures_equal()
32-
def test_coast_iceland():
33-
"""
34-
Test passing in R as a list.
35-
"""
36-
fig_ref, fig_test = Figure(), Figure()
37-
# Use single-character arguments for the reference image
38-
fig_ref.coast(R="-30/-10/60/65", J="m1c", B="", G="p28+r100")
39-
fig_test.coast(
40-
region=[-30, -10, 60, 65], projection="m1c", frame=True, land="p28+r100"
41-
)
42-
return fig_ref, fig_test
43-
44-
45-
@check_figures_equal()
46-
def test_coast_aliases():
47-
"""
48-
Test that all aliases work.
49-
"""
50-
fig_ref, fig_test = Figure(), Figure()
51-
fig_ref.coast(
52-
R="-30/30/-40/40",
53-
J="M25c",
54-
B="afg",
55-
I="1/1p,black",
56-
N="1/0.5p,-",
57-
W="0.25p,white",
58-
G="moccasin",
59-
S="skyblue",
60-
D="i",
61-
A=1000,
62-
L="jCM+c1+w1000k+f+l",
63-
X="a4c",
64-
Y="a10c",
65-
p="135/25",
66-
t=13,
67-
E="MA+gred",
68-
C="blue",
69-
)
70-
fig_test.coast(
71-
region=[-30, 30, -40, 40], # R
72-
projection="M25c", # J
73-
frame="afg", # B
74-
rivers="1/1p,black", # I
75-
borders="1/0.5p,-", # N
76-
shorelines="0.25p,white", # W
77-
land="moccasin", # G
78-
water="skyblue", # S
79-
resolution="i", # D
80-
area_thresh=1000, # A
81-
map_scale="jCM+c1+w1000k+f+l", # L
82-
xshift="a4c", # X
83-
yshift="a10c", # Y
84-
perspective=[135, 25], # p
85-
transparency=13, # t
86-
dcw="MA+gred", # E
87-
lakes="blue", # C
88-
)
89-
return fig_ref, fig_test
90-
91-
9219
@pytest.mark.mpl_image_compare
9320
def test_coast_world_mercator():
9421
"""
95-
Test passing generating a global Mercator map with coastlines.
22+
Test generating a global Mercator map with coastlines.
9623
"""
9724
fig = Figure()
9825
fig.coast(
9926
region=[-180, 180, -80, 80],
100-
projection="M10i",
27+
projection="M15c",
10128
frame="af",
10229
land="#aaaaaa",
103-
resolution="l",
30+
resolution="c",
10431
water="white",
10532
)
10633
return fig
@@ -115,99 +42,33 @@ def test_coast_required_args():
11542
fig.coast(region="EG")
11643

11744

118-
@check_figures_equal()
45+
@pytest.mark.mpl_image_compare
11946
def test_coast_dcw_single():
12047
"""
12148
Test passing a single country code to dcw.
12249
"""
123-
fig_ref, fig_test = Figure(), Figure()
124-
# Use single-character arguments for the reference image
125-
fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="ES+gbisque+pblue")
126-
fig_test.coast(
50+
fig = Figure()
51+
fig.coast(
12752
region=[-10, 15, 25, 44],
12853
frame="a",
12954
projection="M15c",
13055
land="brown",
13156
dcw="ES+gbisque+pblue",
13257
)
133-
return fig_ref, fig_test
134-
135-
136-
@check_figures_equal()
137-
def test_coast_dcw_multiple():
138-
"""
139-
Test passing multiple country code to dcw.
140-
"""
141-
fig_ref, fig_test = Figure(), Figure()
142-
# Use single-character arguments for the reference image
143-
fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="ES,IT+gbisque+pblue")
144-
fig_test.coast(
145-
region=[-10, 15, 25, 44],
146-
frame="a",
147-
projection="M15c",
148-
land="brown",
149-
dcw="ES,IT+gbisque+pblue",
150-
)
151-
return fig_ref, fig_test
58+
return fig
15259

15360

154-
@check_figures_equal()
61+
@pytest.mark.mpl_image_compare
15562
def test_coast_dcw_list():
15663
"""
15764
Test passing a list of country codes and fill options to dcw.
15865
"""
159-
fig_ref, fig_test = Figure(), Figure()
160-
# Use single-character arguments for the reference image
161-
fig_ref.coast(
162-
R="-10/15/25/44",
163-
J="M15c",
164-
B="a",
165-
G="brown",
166-
E=["ES+gbisque+pgreen", "IT+gcyan+pblue"],
167-
)
168-
fig_test.coast(
66+
fig = Figure()
67+
fig.coast(
16968
region=[-10, 15, 25, 44],
17069
frame="a",
17170
projection="M15c",
17271
land="brown",
17372
dcw=["ES+gbisque+pgreen", "IT+gcyan+pblue"],
17473
)
175-
return fig_ref, fig_test
176-
177-
178-
@check_figures_equal()
179-
def test_coast_dcw_continent():
180-
"""
181-
Test passing a continent code to dcw.
182-
"""
183-
fig_ref, fig_test = Figure(), Figure()
184-
# Use single-character arguments for the reference image
185-
fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="=AF+gbisque+pblue")
186-
fig_test.coast(
187-
region=[-10, 15, 25, 44],
188-
frame="a",
189-
projection="M15c",
190-
land="brown",
191-
dcw="=AF+gbisque+pblue",
192-
)
193-
return fig_ref, fig_test
194-
195-
196-
@check_figures_equal()
197-
def test_coast_dcw_state():
198-
"""
199-
Test passing a US state code to dcw.
200-
"""
201-
fig_ref, fig_test = Figure(), Figure()
202-
# Use single-character arguments for the reference image
203-
fig_ref.coast(
204-
R="-75/-69/40/44", J="M15c", B="a", G="brown", E="US.MA+gbisque+pblue"
205-
)
206-
fig_test.coast(
207-
region=[-75, -69, 40, 44],
208-
frame="a",
209-
projection="M15c",
210-
land="brown",
211-
dcw="US.MA+gbisque+pblue",
212-
)
213-
return fig_ref, fig_test
74+
return fig

0 commit comments

Comments
 (0)