From 7a9d24bb13f63367bb005e706a331838b4323d70 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 4 Oct 2020 01:53:42 -0400 Subject: [PATCH 1/2] Disallow passing argumenst like -XNone to GMT --- pygmt/helpers/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index 5004e1b24cf..8689cb08043 100644 --- a/pygmt/helpers/utils.py +++ b/pygmt/helpers/utils.py @@ -127,7 +127,8 @@ 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(dict(R='1/2/3/4', J="X4i", ... B=['xaf', 'yaf', 'WSen'], @@ -140,6 +141,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])) From b2e9acf7855c5dd061f9483fdc68da3338ce1e46 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Sun, 4 Oct 2020 22:20:47 -0400 Subject: [PATCH 2/2] Format codes --- pygmt/helpers/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/utils.py b/pygmt/helpers/utils.py index d0fa60dcbe1..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, X=None, Y=None))) + >>> 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(