1
1
"""
2
- Tests for gmt config.
2
+ Tests for pygmt. config.
3
3
"""
4
4
import pytest
5
5
from pygmt import Figure , config
6
- from pygmt .helpers .testing import check_figures_equal
7
6
8
7
9
8
@pytest .mark .mpl_image_compare
@@ -23,75 +22,53 @@ def test_config():
23
22
region = "0/10/0/10" ,
24
23
projection = "X10c/10c" ,
25
24
frame = ['xaf+l"red label"' , "yaf" , '+t"red annotation"' ],
26
- X = "15c" ,
25
+ xshift = "15c" ,
27
26
)
28
27
29
28
fig .basemap (
30
29
region = "0/10/0/10" ,
31
30
projection = "X10c/10c" ,
32
31
frame = ["af" , '+t"Blue Annotation"' ],
33
- X = "15c" ,
32
+ xshift = "15c" ,
34
33
)
35
34
# Revert to default settings in current figure
36
35
config (FONT_ANNOT_PRIMARY = "black" )
37
36
return fig
38
37
39
38
40
- @check_figures_equal ()
39
+ @pytest . mark . mpl_image_compare
41
40
def test_config_font_one ():
42
41
"""
43
- Test that setting `FONT` config changes all `FONT_*` settings except
44
- `FONT_LOGO`.
42
+ Test that setting FONT config changes all FONT_* settings except FONT_LOGO.
45
43
46
- Specifically, this test only checks that ` FONT_ANNOT_PRIMARY` ,
47
- ` FONT_ANNOT_SECONDARY`, ` FONT_LABEL` , and ` FONT_TITLE` are modified.
44
+ Specifically, this test only checks that FONT_ANNOT_PRIMARY,
45
+ FONT_ANNOT_SECONDARY, FONT_LABEL, and FONT_TITLE are modified.
48
46
"""
49
- fig_ref = Figure ()
50
- with config (
51
- FONT_ANNOT_PRIMARY = "8p,red" ,
52
- FONT_ANNOT_SECONDARY = "8p,red" ,
53
- FONT_LABEL = "8p,red" ,
54
- FONT_TITLE = "8p,red" ,
55
- ):
56
- fig_ref .basemap (R = "0/9/0/9" , J = "C3/3/9c" , Tm = "jTL+w4c+d4.5+l" )
57
- fig_ref .basemap (Tm = "jBR+w5c+d-4.5+l" )
58
-
59
- fig_test = Figure ()
47
+ fig = Figure ()
60
48
with config (FONT = "8p,red" ):
61
- fig_test .basemap (
62
- region = [0 , 9 , 0 , 9 ], projection = "C3/3/9c" , compass = "jTL+w4c+d4.5+l"
63
- )
64
- fig_test .basemap (compass = "jBR+w5c+d-4.5+l" )
65
-
66
- return fig_ref , fig_test
49
+ fig .basemap (region = [0 , 9 , 0 , 9 ], projection = "C3/3/9c" , compass = "jTL+w4c+d4.5+l" )
50
+ fig .basemap (compass = "jBR+w5c+d-4.5+l" )
51
+ return fig
67
52
68
53
69
- @check_figures_equal ()
54
+ @pytest . mark . mpl_image_compare
70
55
def test_config_font_annot ():
71
56
"""
72
- Test that setting ` FONT_ANNOT` config changes both ` FONT_ANNOT_PRIMARY` and
73
- ` FONT_ANNOT_SECONDARY` .
57
+ Test that setting FONT_ANNOT config changes both FONT_ANNOT_PRIMARY and
58
+ FONT_ANNOT_SECONDARY.
74
59
"""
75
- fig_ref = Figure ()
76
- with config (FONT_ANNOT_PRIMARY = "6p,red" , FONT_ANNOT_SECONDARY = "6p,red" ):
77
- fig_ref .basemap (R = "0/9/0/9" , J = "C3/3/9c" , Tm = "jTL+w4c+d4.5" )
78
- fig_ref .basemap (compass = "jBR+w5c+d-4.5" )
79
-
80
- fig_test = Figure ()
60
+ fig = Figure ()
81
61
with config (FONT_ANNOT = "6p,red" ):
82
- fig_test .basemap (
83
- region = [0 , 9 , 0 , 9 ], projection = "C3/3/9c" , compass = "jTL+w4c+d4.5"
84
- )
85
- fig_test .basemap (compass = "jBR+w5c+d-4.5" )
86
-
87
- return fig_ref , fig_test
62
+ fig .basemap (region = [0 , 9 , 0 , 9 ], projection = "C3/3/9c" , compass = "jTL+w4c+d4.5" )
63
+ fig .basemap (compass = "jBR+w5c+d-4.5" )
64
+ return fig
88
65
89
66
90
67
@pytest .mark .mpl_image_compare
91
68
def test_config_format_time_map ():
92
69
"""
93
- Test that setting ` FORMAT_TIME_MAP` config changes both
94
- ` FORMAT_TIME_PRIMARY_MAP` and ` FORMAT_TIME_SECONDARY_MAP` .
70
+ Test that setting FORMAT_TIME_MAP config changes both
71
+ FORMAT_TIME_PRIMARY_MAP and FORMAT_TIME_SECONDARY_MAP.
95
72
"""
96
73
fig = Figure ()
97
74
with config (FORMAT_TIME_MAP = "abbreviation" ):
@@ -107,8 +84,8 @@ def test_config_format_time_map():
107
84
@pytest .mark .mpl_image_compare
108
85
def test_config_map_annot_offset ():
109
86
"""
110
- Test that setting ` MAP_ANNOT_OFFSET` config changes both
111
- ` MAP_ANNOT_OFFSET_PRIMARY` and ` MAP_ANNOT_OFFSET_SECONDARY` .
87
+ Test that setting MAP_ANNOT_OFFSET config changes both
88
+ MAP_ANNOT_OFFSET_PRIMARY and MAP_ANNOT_OFFSET_SECONDARY.
112
89
"""
113
90
fig = Figure ()
114
91
with config (MAP_ANNOT_OFFSET = "15p" ):
@@ -124,8 +101,8 @@ def test_config_map_annot_offset():
124
101
@pytest .mark .mpl_image_compare
125
102
def test_config_map_grid_cross_size ():
126
103
"""
127
- Test that setting ` MAP_GRID_CROSS_SIZE` config changes both
128
- ` MAP_GRID_CROSS_SIZE_PRIMARY` and ` MAP_GRID_CROSS_SIZE_SECONDARY` .
104
+ Test that setting MAP_GRID_CROSS_SIZE config changes both
105
+ MAP_GRID_CROSS_SIZE_PRIMARY and MAP_GRID_CROSS_SIZE_SECONDARY.
129
106
"""
130
107
fig = Figure ()
131
108
with config (MAP_GRID_CROSS_SIZE = "3p" ):
@@ -142,8 +119,8 @@ def test_config_map_grid_cross_size():
142
119
@pytest .mark .mpl_image_compare
143
120
def test_config_map_grid_pen ():
144
121
"""
145
- Test that setting ` MAP_GRID_PEN` config changes both ` MAP_GRID_PEN_PRIMARY`
146
- and ` MAP_GRID_PEN_SECONDARY` .
122
+ Test that setting MAP_GRID_PEN config changes both MAP_GRID_PEN_PRIMARY and
123
+ MAP_GRID_PEN_SECONDARY.
147
124
"""
148
125
fig = Figure ()
149
126
with config (MAP_GRID_PEN = "thick,red" ):
@@ -160,8 +137,8 @@ def test_config_map_grid_pen():
160
137
@pytest .mark .mpl_image_compare
161
138
def test_config_map_tick_length ():
162
139
"""
163
- Test that setting ` MAP_TICK_LENGTH` config changes both
164
- ` MAP_TICK_LENGTH_PRIMARY` and ` MAP_TICK_LENGTH_SECONDARY` .
140
+ Test that setting MAP_TICK_LENGTH config changes both
141
+ MAP_TICK_LENGTH_PRIMARY and MAP_TICK_LENGTH_SECONDARY.
165
142
"""
166
143
fig = Figure ()
167
144
with config (MAP_TICK_LENGTH = "5p" ):
@@ -178,8 +155,8 @@ def test_config_map_tick_length():
178
155
@pytest .mark .mpl_image_compare
179
156
def test_config_map_tick_pen ():
180
157
"""
181
- Test that setting ` MAP_TICK_PEN` config changes both ` MAP_TICK_PEN_PRIMARY`
182
- and ` MAP_TICK_PEN_SECONDARY` .
158
+ Test that setting MAP_TICK_PEN config changes both MAP_TICK_PEN_PRIMARY and
159
+ MAP_TICK_PEN_SECONDARY.
183
160
"""
184
161
fig = Figure ()
185
162
with config (MAP_TICK_PEN = "thick,red" ):
0 commit comments