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,57 @@ 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 (
49
+ fig .basemap (
62
50
region = [0 , 9 , 0 , 9 ], projection = "C3/3/9c" , compass = "jTL+w4c+d4.5+l"
63
51
)
64
- fig_test .basemap (compass = "jBR+w5c+d-4.5+l" )
65
-
66
- return fig_ref , fig_test
52
+ fig .basemap (compass = "jBR+w5c+d-4.5+l" )
53
+ return fig
67
54
68
55
69
- @check_figures_equal ()
56
+ @pytest . mark . mpl_image_compare
70
57
def test_config_font_annot ():
71
58
"""
72
- Test that setting ` FONT_ANNOT` config changes both ` FONT_ANNOT_PRIMARY` and
73
- ` FONT_ANNOT_SECONDARY` .
59
+ Test that setting FONT_ANNOT config changes both FONT_ANNOT_PRIMARY and
60
+ FONT_ANNOT_SECONDARY.
74
61
"""
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 ()
62
+ fig = Figure ()
81
63
with config (FONT_ANNOT = "6p,red" ):
82
- fig_test .basemap (
64
+ fig .basemap (
83
65
region = [0 , 9 , 0 , 9 ], projection = "C3/3/9c" , compass = "jTL+w4c+d4.5"
84
66
)
85
- fig_test .basemap (compass = "jBR+w5c+d-4.5" )
86
-
87
- return fig_ref , fig_test
67
+ fig .basemap (compass = "jBR+w5c+d-4.5" )
68
+ return fig
88
69
89
70
90
71
@pytest .mark .mpl_image_compare
91
72
def test_config_format_time_map ():
92
73
"""
93
- Test that setting ` FORMAT_TIME_MAP` config changes both
94
- ` FORMAT_TIME_PRIMARY_MAP` and ` FORMAT_TIME_SECONDARY_MAP` .
74
+ Test that setting FORMAT_TIME_MAP config changes both
75
+ FORMAT_TIME_PRIMARY_MAP and FORMAT_TIME_SECONDARY_MAP.
95
76
"""
96
77
fig = Figure ()
97
78
with config (FORMAT_TIME_MAP = "abbreviation" ):
@@ -107,8 +88,8 @@ def test_config_format_time_map():
107
88
@pytest .mark .mpl_image_compare
108
89
def test_config_map_annot_offset ():
109
90
"""
110
- Test that setting ` MAP_ANNOT_OFFSET` config changes both
111
- ` MAP_ANNOT_OFFSET_PRIMARY` and ` MAP_ANNOT_OFFSET_SECONDARY` .
91
+ Test that setting MAP_ANNOT_OFFSET config changes both
92
+ MAP_ANNOT_OFFSET_PRIMARY and MAP_ANNOT_OFFSET_SECONDARY.
112
93
"""
113
94
fig = Figure ()
114
95
with config (MAP_ANNOT_OFFSET = "15p" ):
@@ -124,8 +105,8 @@ def test_config_map_annot_offset():
124
105
@pytest .mark .mpl_image_compare
125
106
def test_config_map_grid_cross_size ():
126
107
"""
127
- Test that setting ` MAP_GRID_CROSS_SIZE` config changes both
128
- ` MAP_GRID_CROSS_SIZE_PRIMARY` and ` MAP_GRID_CROSS_SIZE_SECONDARY` .
108
+ Test that setting MAP_GRID_CROSS_SIZE config changes both
109
+ MAP_GRID_CROSS_SIZE_PRIMARY and MAP_GRID_CROSS_SIZE_SECONDARY.
129
110
"""
130
111
fig = Figure ()
131
112
with config (MAP_GRID_CROSS_SIZE = "3p" ):
@@ -142,8 +123,8 @@ def test_config_map_grid_cross_size():
142
123
@pytest .mark .mpl_image_compare
143
124
def test_config_map_grid_pen ():
144
125
"""
145
- Test that setting ` MAP_GRID_PEN` config changes both ` MAP_GRID_PEN_PRIMARY`
146
- and ` MAP_GRID_PEN_SECONDARY` .
126
+ Test that setting MAP_GRID_PEN config changes both MAP_GRID_PEN_PRIMARY
127
+ and MAP_GRID_PEN_SECONDARY.
147
128
"""
148
129
fig = Figure ()
149
130
with config (MAP_GRID_PEN = "thick,red" ):
@@ -160,8 +141,8 @@ def test_config_map_grid_pen():
160
141
@pytest .mark .mpl_image_compare
161
142
def test_config_map_tick_length ():
162
143
"""
163
- Test that setting ` MAP_TICK_LENGTH` config changes both
164
- ` MAP_TICK_LENGTH_PRIMARY` and ` MAP_TICK_LENGTH_SECONDARY` .
144
+ Test that setting MAP_TICK_LENGTH config changes both
145
+ MAP_TICK_LENGTH_PRIMARY and MAP_TICK_LENGTH_SECONDARY.
165
146
"""
166
147
fig = Figure ()
167
148
with config (MAP_TICK_LENGTH = "5p" ):
@@ -178,8 +159,8 @@ def test_config_map_tick_length():
178
159
@pytest .mark .mpl_image_compare
179
160
def test_config_map_tick_pen ():
180
161
"""
181
- Test that setting ` MAP_TICK_PEN` config changes both ` MAP_TICK_PEN_PRIMARY`
182
- and ` MAP_TICK_PEN_SECONDARY` .
162
+ Test that setting MAP_TICK_PEN config changes both MAP_TICK_PEN_PRIMARY
163
+ and MAP_TICK_PEN_SECONDARY.
183
164
"""
184
165
fig = Figure ()
185
166
with config (MAP_TICK_PEN = "thick,red" ):
0 commit comments