Skip to content

Commit 0ef29f8

Browse files
authored
Fix the bug when passing a sequence that contains True to a parameter (#3982)
1 parent c156826 commit 0ef29f8

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

pygmt/helpers/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ def build_arg_list( # noqa: PLR0912
524524
['-A1/2/3/4', '-BWSen', '-Bxaf', '-Byaf', '-C1p', '-C2p']
525525
>>> build_arg_list(dict(B=["af", "WSne+tBlank Space"]))
526526
['-BWSne+tBlank Space', '-Baf']
527+
>>> build_arg_list(dict(B=[True, "+tTitle"]))
528+
['-B', '-B+tTitle']
527529
>>> build_arg_list(dict(F='+t"Empty Spaces"'))
528530
['-F+t"Empty Spaces"']
529531
>>> build_arg_list(dict(l="'Void Space'"))
@@ -565,7 +567,10 @@ def build_arg_list( # noqa: PLR0912
565567
elif value is True:
566568
gmt_args.append(f"-{key}")
567569
elif is_nonstr_iter(value):
568-
gmt_args.extend(f"-{key}{_value}" for _value in value)
570+
gmt_args.extend(
571+
f"-{key}{_value}" if _value is not True else f"-{key}"
572+
for _value in value
573+
)
569574
else:
570575
gmt_args.append(f"-{key}{value}")
571576

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
outs:
2+
- md5: b04af7fe4c42e405adb600cc3d6d3272
3+
size: 11679
4+
hash: md5
5+
path: test_basemap_frame_sequence_true.png

pygmt/tests/test_basemap.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,15 @@ def test_basemap_subplot():
143143
with fig.set_panel(panel=1):
144144
fig.basemap(region=[0, 10, 0, 10], projection="X?")
145145
return fig
146+
147+
148+
@pytest.mark.mpl_image_compare
149+
def test_basemap_frame_sequence_true():
150+
"""
151+
Test that passing a sequence with True works.
152+
153+
Test for https://github.com/GenericMappingTools/pygmt/issues/3981.
154+
"""
155+
fig = Figure()
156+
fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=[True, "WSen"])
157+
return fig

0 commit comments

Comments
 (0)