Skip to content

Commit

Permalink
woops
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Nov 25, 2023
1 parent e270bd0 commit b3dea0f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pandas/_libs/tslibs/fields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ cdef ndarray[int64_t] _rounddown_int64(values, int64_t unit):
cdef:
Py_ssize_t i, n = len(values)
ndarray[int64_t] result = np.empty(n, dtype="i8")
int64_t res, value, half, remainder, quotient
int64_t res, value, remainder, half

half = unit // 2

Expand All @@ -761,18 +761,15 @@ cdef ndarray[int64_t] _rounddown_int64(values, int64_t unit):
res = NPY_NAT
else:
# This adjustment is the only difference between rounddown_int64
# and _round_nearest_int64
value = value - unit // 2
quotient, remainder = divmod(value, unit)
if remainder > half:
res = value + (unit - remainder)
elif remainder == half and quotient % 2:
res = value + (unit - remainder)
# and _ceil_int64
value = value - half
remainder = value % unit
if remainder == 0:
res = value
else:
res = value - remainder
res = value + (unit - remainder)

result[i] = res

return result


Expand Down

0 comments on commit b3dea0f

Please sign in to comment.