From 96a32b9563c8abd3581377918e0b96998f4144f2 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Thu, 8 Oct 2020 00:59:11 -0400 Subject: [PATCH] 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. --- pygmt/helpers/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index 79b65fc0048..a72dcd6bb51 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -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( @@ -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]))