Skip to content

Commit 96a32b9

Browse files
authored
Disallow passing arguments like -XNone to GMT (#639)
Arguments like -XNone are invalid for GMT. This PR updates the function build_arg_string and checks if any value is None. If yes, remove the argument.
1 parent b1ef6bf commit 96a32b9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pygmt/helpers/utils.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ def build_arg_string(kwargs):
127127
Examples
128128
--------
129129
130-
>>> print(build_arg_string(dict(R="1/2/3/4", J="X4i", P="", E=200)))
130+
>>> print(
131+
... build_arg_string(
132+
... dict(R="1/2/3/4", J="X4i", P="", E=200, X=None, Y=None)
133+
... )
134+
... )
131135
-E200 -JX4i -P -R1/2/3/4
132136
>>> print(
133137
... build_arg_string(
@@ -147,6 +151,8 @@ def build_arg_string(kwargs):
147151
if is_nonstr_iter(kwargs[key]):
148152
for value in kwargs[key]:
149153
sorted_args.append("-{}{}".format(key, value))
154+
elif kwargs[key] is None: # arguments like -XNone are invalid
155+
continue
150156
else:
151157
sorted_args.append("-{}{}".format(key, kwargs[key]))
152158

0 commit comments

Comments
 (0)