Skip to content

CLN: de-duplicate paths in tslibs #34400

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

Merged
merged 7 commits into from
May 27, 2020
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ cpdef bint _does_string_look_like_datetime(str py_string):
return True


cdef inline object _parse_dateabbr_string(object date_string, object default,
cdef inline object _parse_dateabbr_string(object date_string, datetime default,
object freq):
cdef:
object ret
Expand Down
17 changes: 1 addition & 16 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -964,23 +964,8 @@ def dt64arr_to_periodarr(const int64_t[:] dtarr, int freq, tz=None):
"""
cdef:
int64_t[:] out
Py_ssize_t i, l
Copy link
Contributor

Choose a reason for hiding this comment

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

do we even need this routine any longer? (e.g. just call localize_dt64arr_to_period in the caller)

Copy link
Member Author

Choose a reason for hiding this comment

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

sure

npy_datetimestruct dts

l = len(dtarr)

out = np.empty(l, dtype='i8')

if tz is None:
with nogil:
for i in range(l):
if dtarr[i] == NPY_NAT:
out[i] = NPY_NAT
continue
dt64_to_dtstruct(dtarr[i], &dts)
out[i] = get_period_ordinal(&dts, freq)
else:
out = localize_dt64arr_to_period(dtarr, freq, tz)
out = localize_dt64arr_to_period(dtarr, freq, tz)
return out.base # .base to access underlying np.ndarray


Expand Down
16 changes: 4 additions & 12 deletions pandas/_libs/tslibs/resolution.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,19 @@ cdef:

# ----------------------------------------------------------------------

cpdef resolution(const int64_t[:] stamps, tz=None):
def resolution(const int64_t[:] stamps, tz=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

not called in cython anylonger?

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure if it ever was

cdef:
Py_ssize_t i, n = len(stamps)
npy_datetimestruct dts
int reso = RESO_DAY, curr_reso

if tz is not None:
tz = maybe_get_tz(tz)
return _reso_local(stamps, tz)


cdef _reso_local(const int64_t[:] stamps, object tz):
cdef:
Py_ssize_t i, n = len(stamps)
int reso = RESO_DAY, curr_reso
ndarray[int64_t] trans
int64_t[:] deltas
Py_ssize_t[:] pos
npy_datetimestruct dts
int64_t local_val, delta

if tz is not None:
tz = maybe_get_tz(tz)

if is_utc(tz) or tz is None:
for i in range(n):
if stamps[i] == NPY_NAT:
Expand Down
1 change: 0 additions & 1 deletion pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import datetime, timedelta
import operator

import numpy as np

Expand Down