Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xcdat/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def _create_time_bounds( # noqa: C901
if isinstance(diff, np.timedelta64):
diff = pd.to_timedelta(diff)

hrs = diff.seconds / 3600
hrs = diff.total_seconds() / 3600
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If diff exceeds 24 hours, hrs will be >=24 and daily_subfreq = int(24 / hrs) becomes zero, leading to downstream errors. Consider adding a guard to ensure hrs is within (0, 24] or handle diff > 24h explicitly before computing daily_subfreq.

Suggested change
hrs = diff.total_seconds() / 3600
hrs = diff.total_seconds() / 3600
if not (0 < hrs <= 24):
raise ValueError(
f"Invalid time difference: {hrs} hours. Expected a value in the range (0, 24]."
)

Copilot uses AI. Check for mistakes.
daily_subfreq = int(24 / hrs) # type: ignore

time_bnds = self._create_daily_time_bounds(
Expand Down
Loading