1
1
"""
2
- Tests for coast.
2
+ Tests for fig. coast.
3
3
"""
4
4
import pytest
5
5
from pygmt import Figure
6
6
from pygmt .exceptions import GMTInvalidInput
7
- from pygmt .helpers .testing import check_figures_equal
8
7
9
8
10
9
@pytest .mark .mpl_image_compare
11
- def test_coast ():
10
+ def test_coast_region ():
12
11
"""
13
- Simple plot from the GMT docs .
12
+ Test plotting a regional map with coastlines .
14
13
"""
15
14
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 )
28
16
return fig
29
17
30
18
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
-
92
19
@pytest .mark .mpl_image_compare
93
20
def test_coast_world_mercator ():
94
21
"""
95
- Test passing generating a global Mercator map with coastlines.
22
+ Test generating a global Mercator map with coastlines.
96
23
"""
97
24
fig = Figure ()
98
25
fig .coast (
99
26
region = [- 180 , 180 , - 80 , 80 ],
100
- projection = "M10i " ,
27
+ projection = "M15c " ,
101
28
frame = "af" ,
102
29
land = "#aaaaaa" ,
103
- resolution = "l " ,
30
+ resolution = "c " ,
104
31
water = "white" ,
105
32
)
106
33
return fig
@@ -115,99 +42,33 @@ def test_coast_required_args():
115
42
fig .coast (region = "EG" )
116
43
117
44
118
- @check_figures_equal ()
45
+ @pytest . mark . mpl_image_compare
119
46
def test_coast_dcw_single ():
120
47
"""
121
48
Test passing a single country code to dcw.
122
49
"""
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 (
127
52
region = [- 10 , 15 , 25 , 44 ],
128
53
frame = "a" ,
129
54
projection = "M15c" ,
130
55
land = "brown" ,
131
56
dcw = "ES+gbisque+pblue" ,
132
57
)
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
152
59
153
60
154
- @check_figures_equal ()
61
+ @pytest . mark . mpl_image_compare
155
62
def test_coast_dcw_list ():
156
63
"""
157
64
Test passing a list of country codes and fill options to dcw.
158
65
"""
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 (
169
68
region = [- 10 , 15 , 25 , 44 ],
170
69
frame = "a" ,
171
70
projection = "M15c" ,
172
71
land = "brown" ,
173
72
dcw = ["ES+gbisque+pgreen" , "IT+gcyan+pblue" ],
174
73
)
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