Skip to content

Commit

Permalink
fix some checks
Browse files Browse the repository at this point in the history
  • Loading branch information
headtr1ck committed Jul 12, 2024
1 parent 16bee67 commit 602c3cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xarray/core/resample_cftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ def __init__(
if offset is not None:
try:
self.offset = _convert_offset_to_timedelta(offset)
except (AttributeError, TypeError) as error:
except (ValueError, TypeError) as error:
raise ValueError(
f"offset must be a datetime.timedelta object or an offset string "
f"that can be converted to a timedelta. Got {type(offset)} instead."
f"that can be converted to a timedelta. Got {type(offset)} instead."
) from error
else:
self.offset = None
Expand Down Expand Up @@ -505,8 +505,8 @@ def _convert_offset_to_timedelta(
return offset
if isinstance(offset, (str, Tick)):
timedelta_cftime_offset = to_offset(offset)
assert isinstance(timedelta_cftime_offset, Tick)
return timedelta_cftime_offset.as_timedelta()
if isinstance(timedelta_cftime_offset, Tick):
return timedelta_cftime_offset.as_timedelta()
raise TypeError(f"Expected timedelta, str or Tick, got {type(offset)}")


Expand Down

0 comments on commit 602c3cf

Please sign in to comment.