Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e27a0da
refactor npy_datetimestruct_to_datetime
WillAyd Sep 15, 2023
0dea606
Used builtin overflow directives
WillAyd Oct 17, 2023
d6a24f3
macro fixups
WillAyd Oct 17, 2023
21e919c
more macro cleanups
WillAyd Oct 17, 2023
6302f2f
more macro refactor
WillAyd Oct 17, 2023
e2646a6
musllinux c support
WillAyd Oct 18, 2023
5852d20
Merge remote-tracking branch 'upstream/main' into refactor-np-datetime
WillAyd Oct 19, 2023
f55a58a
macro cleanup
WillAyd Oct 19, 2023
057e74f
more refactor
WillAyd Oct 19, 2023
2d6d5fc
fix cython warning
WillAyd Oct 19, 2023
e65e229
windows fix
WillAyd Oct 19, 2023
af29e7c
Raise Outofboundsdatetime
WillAyd Oct 20, 2023
b69b489
Merge remote-tracking branch 'upstream/main' into refactor-np-datetime
WillAyd Oct 20, 2023
f9e5e35
cleanup GIL warnings
WillAyd Oct 20, 2023
1b89dfe
more error handling cleanup
WillAyd Oct 20, 2023
73a1507
updates
WillAyd Oct 20, 2023
ef24509
error message update
WillAyd Oct 20, 2023
2240b09
error fixups
WillAyd Oct 20, 2023
1640002
test fixup
WillAyd Oct 22, 2023
9cdb9c9
clang-format
WillAyd Oct 23, 2023
9e0cec0
Merge branch 'main' into refactor-np-datetime
WillAyd Oct 23, 2023
25f3edf
Merge branch 'main' into refactor-np-datetime
WillAyd Oct 24, 2023
5c09a13
Merge branch 'main' into refactor-np-datetime
WillAyd Oct 26, 2023
4d8696c
updates
WillAyd Oct 26, 2023
b3d5b7c
fixed error message
WillAyd Oct 26, 2023
2f60947
try nogil
WillAyd Oct 26, 2023
f26c924
Merge remote-tracking branch 'upstream/main' into refactor-np-datetime
WillAyd Nov 1, 2023
03315fc
revert offsets changes
WillAyd Nov 1, 2023
b3a80b4
simplified error handling
WillAyd Nov 1, 2023
038db5f
period fixup
WillAyd Nov 1, 2023
df2a4df
fixed test failure
WillAyd Nov 1, 2023
1afb12d
try speedup
WillAyd Nov 1, 2023
e293642
updated benchmark
WillAyd Nov 2, 2023
2203421
Merge remote-tracking branch 'upstream/main' into refactor-np-datetime
WillAyd Nov 2, 2023
7ee90dd
revert noexcepts
WillAyd Nov 3, 2023
81f32a9
Merge remote-tracking branch 'upstream/main' into refactor-np-datetime
WillAyd Nov 3, 2023
8d918dc
Merge branch 'main' into refactor-np-datetime
WillAyd Nov 6, 2023
7e8571f
Merge remote-tracking branch 'upstream/main' into refactor-np-datetime
WillAyd Nov 8, 2023
07e8106
Merge branch 'main' into refactor-np-datetime
WillAyd Nov 10, 2023
eab64ac
shared function for dts formatting
WillAyd Nov 10, 2023
7fbd191
import -> cimport
WillAyd Nov 10, 2023
4eba919
pass address
WillAyd Nov 10, 2023
9e1914d
typo
WillAyd Nov 10, 2023
188eb10
Merge branch 'main' into refactor-np-datetime
WillAyd Nov 13, 2023
162c858
remove comment
WillAyd Nov 14, 2023
de90a2f
cdef object -> str
WillAyd Nov 14, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplified error handling
  • Loading branch information
WillAyd committed Nov 1, 2023
commit b3a80b4b96d7080179b3c8f53a936e35406da43b
10 changes: 2 additions & 8 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,7 @@ cdef _TSObject convert_datetime_to_tsobject(
if nanos:
obj.dts.ps = nanos * 1000

try:
obj.value = npy_datetimestruct_to_datetime(reso, &obj.dts)
except OverflowError as err:
raise OutOfBoundsDatetime("Out of bounds nanosecond timestamp") from err
obj.value = npy_datetimestruct_to_datetime(reso, &obj.dts)

if obj.tzinfo is not None and not is_utc(obj.tzinfo):
offset = get_utcoffset(obj.tzinfo, ts)
Expand Down Expand Up @@ -526,10 +523,7 @@ cdef _TSObject convert_str_to_tsobject(str ts, tzinfo tz, str unit,
obj = _TSObject()
obj.dts = dts
obj.creso = reso
try:
ival = npy_datetimestruct_to_datetime(reso, &dts)
except OverflowError as err:
raise OutOfBoundsDatetime from err
ival = npy_datetimestruct_to_datetime(reso, &dts)

if out_local == 1:
obj.tzinfo = timezone(timedelta(minutes=out_tzoffset))
Expand Down
5 changes: 1 addition & 4 deletions pandas/_libs/tslibs/np_datetime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,7 @@ cpdef ndarray astype_overflowsafe(
else:
raise
else:
try:
new_value = npy_datetimestruct_to_datetime(to_unit, &dts)
except OverflowError as err:
raise OutOfBoundsDatetime from err
new_value = npy_datetimestruct_to_datetime(to_unit, &dts)

# Analogous to: iresult[i] = new_value
(<int64_t*>cnp.PyArray_MultiIter_DATA(mi, 0))[0] = new_value
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/period.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ from .np_datetime cimport npy_datetimestruct


cdef bint is_period_object(object obj)
cdef int64_t get_period_ordinal(npy_datetimestruct *dts, int freq)
cdef int64_t get_period_ordinal(npy_datetimestruct *dts, int freq) except? -1
5 changes: 1 addition & 4 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,7 @@ cdef int64_t unix_date_from_ymd(int year, int month, int day) except? -1 nogil:
dts.year = year
dts.month = month
dts.day = day

unix_date = npy_datetimestruct_to_datetime(NPY_FR_D, &dts)

return unix_date


Expand All @@ -749,7 +747,6 @@ cdef int64_t dts_to_year_ordinal(npy_datetimestruct *dts, int to_end) except? -1
int64_t result

result = npy_datetimestruct_to_datetime(NPY_DATETIMEUNIT.NPY_FR_Y, dts)

if dts.month > to_end:
return result + 1
else:
Expand Down Expand Up @@ -777,7 +774,7 @@ cdef int get_anchor_month(int freq, int freq_group) noexcept nogil:
# specifically _dont_ use cdvision or else ordinals near -1 are assigned to
# incorrect dates GH#19643
@cython.cdivision(False)
cdef int64_t get_period_ordinal(npy_datetimestruct *dts, int freq):
cdef int64_t get_period_ordinal(npy_datetimestruct *dts, int freq) except? -1:
"""
Generate an ordinal in period space

Expand Down
8 changes: 2 additions & 6 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,8 @@ cdef class _Timestamp(ABCTimestamp):

if own_tz is not None and not is_utc(own_tz):
pydatetime_to_dtstruct(self, &dts)
try:
# TODO: can + self.nanosecond also overflow here?
val = npy_datetimestruct_to_datetime(
self._creso, &dts) + self.nanosecond
except OverflowError as err:
raise OutOfBoundsDatetime from err
# TODO: can + self.nanosecond also overflow here?
val = npy_datetimestruct_to_datetime(self._creso, &dts) + self.nanosecond
else:
val = self._value
return val
Expand Down