Skip to content

Commit c29e632

Browse files
committed
Ensure spaces in pygmt.config arguments can work
Also added a regression test for FORMAT_DATE_MAP="o dd".
1 parent dd849cb commit c29e632

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

pygmt/src/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, **kwargs):
5555
self.old_defaults[key] = lib.get_default(key)
5656

5757
# call gmt set to change GMT defaults
58-
arg_str = " ".join([f"{key}={value}" for key, value in kwargs.items()])
58+
arg_str = " ".join([f'{key}="{value}"' for key, value in kwargs.items()])
5959
with Session() as lib:
6060
lib.call_module("set", arg_str)
6161

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 3619720cdfcd857cbdbb49ed7fe6e930
3+
size: 1392
4+
path: test_config_format_date_map.png

pygmt/tests/test_config.py

+19
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ def test_config_font_annot():
6464
return fig
6565

6666

67+
@pytest.mark.mpl_image_compare
68+
def test_config_format_date_map():
69+
"""
70+
Test that setting FORMAT_DATE_MAP config changes how the output date string
71+
is plotted.
72+
73+
Note the space in 'o dd', this acts as a regression test for
74+
https://github.com/GenericMappingTools/pygmt/issues/247.
75+
"""
76+
fig = Figure()
77+
with config(FORMAT_DATE_MAP="o dd"):
78+
fig.basemap(
79+
region=["1969-7-21T", "1969-7-23T", 0, 1],
80+
projection="X2.5c/0.1c",
81+
frame=["sxa1D", "S"],
82+
)
83+
return fig
84+
85+
6786
@pytest.mark.mpl_image_compare
6887
def test_config_format_time_map():
6988
"""

0 commit comments

Comments
 (0)