Skip to content

Add/reorganize scalar Timedelta tests #46936

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

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aa47af9
add more Timedelta tests
patrickmckenna May 3, 2022
0957c27
whoops, toolz is optional
patrickmckenna May 4, 2022
89b2431
s/OverflowError/OutOfBoundsTimedelta where relevant
patrickmckenna May 4, 2022
51eb151
catch correct error in Timedelta sub
patrickmckenna May 4, 2022
36d37dc
extract overflow-checking wrapper fcn, add tests
patrickmckenna May 4, 2022
ef09bb9
Merge remote-tracking branch 'upstream/main' into td-constructor
patrickmckenna May 4, 2022
d53d1ce
simplify Timedelta ctor, fix tests
patrickmckenna May 5, 2022
e788c25
Merge remote-tracking branch 'upstream/main' into td64-tests
patrickmckenna May 5, 2022
d995243
test, linter fixes
patrickmckenna May 5, 2022
43291f8
Merge remote-tracking branch 'upstream/main' into td64-tests
patrickmckenna May 5, 2022
4247286
add wrapper for overflow-checked int/float ops
patrickmckenna May 5, 2022
33203b3
wip: lots more tests, consolidate overflow checking
patrickmckenna May 6, 2022
1e73327
Merge remote-tracking branch 'upstream/main' into td64-tests
patrickmckenna May 6, 2022
a72d4e0
more test cleanup
patrickmckenna May 7, 2022
7a7418a
handle older and newer cython semantics
patrickmckenna May 8, 2022
b5e62d6
misc. small fixes
patrickmckenna May 8, 2022
42e597c
DRY up tests
patrickmckenna May 8, 2022
36eb26f
Merge remote-tracking branch 'upstream/main' into td64-tests
patrickmckenna May 10, 2022
c9e209e
consolidate Timedelta creation
patrickmckenna May 10, 2022
4a73340
remove unused stuff
patrickmckenna May 10, 2022
1bc2741
describe current organization, PR feedback
patrickmckenna May 10, 2022
f00539f
use preferred names
patrickmckenna May 11, 2022
99f927e
Merge remote-tracking branch 'upstream/main' into td64-tests
patrickmckenna May 11, 2022
d0967da
perf optimizations
patrickmckenna May 11, 2022
0dbf13d
Merge remote-tracking branch 'upstream/main' into td64-tests
patrickmckenna May 15, 2022
a913282
Merge remote-tracking branch 'upstream/main' into td64-tests
patrickmckenna May 17, 2022
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
5 changes: 5 additions & 0 deletions pandas/_libs/ops.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from numpy cimport int64_t


cpdef int64_t calc_int_int(object op, int64_t a, int64_t b) except? -1
cpdef int64_t calc_int_float(object op, int64_t a, double b) except? -1
2 changes: 2 additions & 0 deletions pandas/_libs/ops.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ def maybe_convert_bool(
*,
convert_to_masked_nullable: Literal[True],
) -> tuple[np.ndarray, np.ndarray]: ...
def calc_int_int(op, left: int, right: int) -> int: ...
def calc_int_float(op, left: int, right: float) -> int: ...
18 changes: 18 additions & 0 deletions pandas/_libs/ops.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import numpy as np

from numpy cimport (
import_array,
int64_t,
ndarray,
uint8_t,
)
Expand Down Expand Up @@ -308,3 +309,20 @@ def maybe_convert_bool(ndarray[object] arr,
return (arr, None)
else:
return (result.view(np.bool_), None)


@cython.overflowcheck(True)
cpdef int64_t calc_int_int(object op, int64_t a, int64_t b) except? -1:
"""
Calculate op(a, b) and return the result. Raises OverflowError if converting either
operand or the result to an int64_t would overflow.
"""
return op(a, b)

@cython.overflowcheck(True)
cpdef int64_t calc_int_float(object op, int64_t a, double b) except? -1:
"""
Calculate op(a, b) and return the result. Raises OverflowError if converting either
operand or the result would overflow.
"""
return op(a, b)
Loading