Skip to content

Commit

Permalink
Refactor the kwargs_to_strings decorator to avoid try-except in loops (
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Dec 16, 2023
1 parent 25914d8 commit 28e3cf3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,15 +757,12 @@ def new_module(*args, **kwargs):
else:
continue

issequence = fmt in separators
if issequence and is_nonstr_iter(value):
if fmt in separators and is_nonstr_iter(value):
for index, item in enumerate(value):
try:
if " " in str(item):
# Check if there is a space " " when converting
# a pandas.Timestamp/xr.DataArray to a string.
# If so, use np.datetime_as_string instead.
assert " " not in str(item)
except AssertionError:
# Convert datetime-like item to ISO 8601
# string format like YYYY-MM-DDThh:mm:ss.ffffff.
value[index] = np.datetime_as_string(
Expand Down

0 comments on commit 28e3cf3

Please sign in to comment.