-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wraparound/overflow in date_range #19740
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2137,11 +2137,30 @@ def _generate_regular_range(start, end, periods, offset): | |
tz = start.tz | ||
elif start is not None: | ||
b = Timestamp(start).value | ||
e = b + np.int64(periods) * stride | ||
try: | ||
with np.errstate(over='raise'): | ||
# raise instead of incorrectly wrapping around GH#19740 | ||
e = b + np.int64(periods) * stride | ||
except (FloatingPointError, OverflowError): | ||
raise libts.OutOfBoundsDatetime('Cannot generate range with ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is already a routine to do this checking (not called here) pls use it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. greo for overflow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. grep the codebase (I put it below) |
||
'start={start} and ' | ||
'periods={periods}' | ||
.format(start=start, | ||
periods=periods)) | ||
|
||
tz = start.tz | ||
elif end is not None: | ||
e = Timestamp(end).value + stride | ||
b = e - np.int64(periods) * stride | ||
try: | ||
with np.errstate(over='raise'): | ||
# raise instead of incorrectly wrapping around GH#19740 | ||
b = e - np.int64(periods) * stride | ||
except (FloatingPointError, OverflowError): | ||
raise libts.OutOfBoundsDatetime('Cannot generate range with ' | ||
'start={start} and ' | ||
'periods={periods}' | ||
.format(start=start, | ||
periods=periods)) | ||
tz = end.tz | ||
else: | ||
raise ValueError("at least 'start' or 'end' should be specified " | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number here as well