Skip to content

Commit

Permalink
Disallow passing arguments like -XNone to GMT (#639)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
seisman authored Oct 8, 2020
1 parent b1ef6bf commit 96a32b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def build_arg_string(kwargs):
Examples
--------
>>> print(build_arg_string(dict(R="1/2/3/4", J="X4i", P="", E=200)))
>>> print(
... build_arg_string(
... dict(R="1/2/3/4", J="X4i", P="", E=200, X=None, Y=None)
... )
... )
-E200 -JX4i -P -R1/2/3/4
>>> print(
... build_arg_string(
Expand All @@ -147,6 +151,8 @@ def build_arg_string(kwargs):
if is_nonstr_iter(kwargs[key]):
for value in kwargs[key]:
sorted_args.append("-{}{}".format(key, value))
elif kwargs[key] is None: # arguments like -XNone are invalid
continue
else:
sorted_args.append("-{}{}".format(key, kwargs[key]))

Expand Down

0 comments on commit 96a32b9

Please sign in to comment.