Skip to content

Commit ac04502

Browse files
committed
Use the improved kwargs_to_strings decorator
1 parent 62c375a commit ac04502

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

pygmt/src/timestamp.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
from packaging.version import Version
77
from pygmt.clib import Session, __gmt_version__
8-
from pygmt.helpers import build_arg_string, is_nonstr_iter
8+
from pygmt.helpers import build_arg_string, kwargs_to_strings
99

1010
__doctest_skip__ = ["timestamp"]
1111

1212

13+
@kwargs_to_strings(offset="sequence")
1314
def timestamp(
1415
self,
1516
text=None,
@@ -83,14 +84,11 @@ def timestamp(
8384
kwdict["U"] += f"{label}"
8485
kwdict["U"] += f"+j{justification}"
8586

86-
if is_nonstr_iter(offset): # given a tuple
87-
kwdict["U"] += "+o" + "/".join(f"{item}" for item in offset)
88-
elif "/" not in offset and Version(__gmt_version__) <= Version("6.4.0"):
87+
if "/" not in offset and Version(__gmt_version__) <= Version("6.4.0"):
8988
# Giving a single offset doesn't work in GMT <= 6.4.0.
9089
# See https://github.com/GenericMappingTools/gmt/issues/7107.
91-
kwdict["U"] += f"+o{offset}/{offset}"
92-
else:
93-
kwdict["U"] += f"+o{offset}"
90+
offset = f"{offset}/{offset}"
91+
kwdict["U"] += f"+o{offset}"
9492

9593
# The +t modifier was added in GMT 6.5.0.
9694
# See https://github.com/GenericMappingTools/gmt/pull/7127.

pygmt/src/which.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
GMTTempFile,
77
build_arg_string,
88
fmt_docstring,
9-
is_nonstr_iter,
9+
kwargs_to_strings,
1010
use_alias,
1111
)
1212

1313

1414
@fmt_docstring
1515
@use_alias(G="download", V="verbose")
16+
@kwargs_to_strings(fname="sequence_space")
1617
def which(fname, **kwargs):
1718
r"""
1819
Find the full path to specified files.
@@ -62,9 +63,6 @@ def which(fname, **kwargs):
6263
FileNotFoundError
6364
If the file is not found.
6465
"""
65-
if is_nonstr_iter(fname): # Got a list of files
66-
fname = " ".join(fname)
67-
6866
with GMTTempFile() as tmpfile:
6967
with Session() as lib:
7068
lib.call_module(

0 commit comments

Comments
 (0)