Skip to content

Commit

Permalink
Ensure spaces in pygmt.config arguments can work
Browse files Browse the repository at this point in the history
Also added a regression test for
FORMAT_DATE_MAP="o dd".
  • Loading branch information
weiji14 committed Jan 10, 2022
1 parent dd849cb commit c29e632
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pygmt/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, **kwargs):
self.old_defaults[key] = lib.get_default(key)

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

Expand Down
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_format_date_map.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 3619720cdfcd857cbdbb49ed7fe6e930
size: 1392
path: test_config_format_date_map.png
19 changes: 19 additions & 0 deletions pygmt/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ def test_config_font_annot():
return fig


@pytest.mark.mpl_image_compare
def test_config_format_date_map():
"""
Test that setting FORMAT_DATE_MAP config changes how the output date string
is plotted.
Note the space in 'o dd', this acts as a regression test for
https://github.com/GenericMappingTools/pygmt/issues/247.
"""
fig = Figure()
with config(FORMAT_DATE_MAP="o dd"):
fig.basemap(
region=["1969-7-21T", "1969-7-23T", 0, 1],
projection="X2.5c/0.1c",
frame=["sxa1D", "S"],
)
return fig


@pytest.mark.mpl_image_compare
def test_config_format_time_map():
"""
Expand Down

0 comments on commit c29e632

Please sign in to comment.