Skip to content

Added const where avaible #32893

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
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,12 @@ cdef inline void localize_tso(_TSObject obj, tzinfo tz):
obj.tzinfo = tz


cdef inline bint _infer_tsobject_fold(_TSObject obj, ndarray[int64_t] trans,
int64_t[:] deltas, int32_t pos):
cdef inline bint _infer_tsobject_fold(
_TSObject obj,
const int64_t[:] trans,
const int64_t[:] deltas,
int32_t pos,
):
"""
Infer _TSObject fold property from value by assuming 0 and then setting
to 1 if necessary.
Expand Down Expand Up @@ -738,7 +742,7 @@ def normalize_i8_timestamps(int64_t[:] stamps, object tz):

@cython.wraparound(False)
@cython.boundscheck(False)
cdef int64_t[:] _normalize_local(int64_t[:] stamps, tzinfo tz):
cdef int64_t[:] _normalize_local(const int64_t[:] stamps, tzinfo tz):
"""
Normalize each of the (nanosecond) timestamps in the given array by
rounding down to the beginning of the day (i.e. midnight) for the
Expand Down Expand Up @@ -818,7 +822,7 @@ cdef inline int64_t _normalized_stamp(npy_datetimestruct *dts) nogil:

@cython.wraparound(False)
@cython.boundscheck(False)
def is_date_array_normalized(int64_t[:] stamps, object tz=None):
def is_date_array_normalized(const int64_t[:] stamps, object tz=None):
"""
Check if all of the given (nanosecond) timestamps are normalized to
midnight, i.e. hour == minute == second == 0. If the optional timezone
Expand Down
11 changes: 8 additions & 3 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,13 @@ cdef inline int month_add_months(npy_datetimestruct dts, int months) nogil:

@cython.wraparound(False)
@cython.boundscheck(False)
def shift_quarters(int64_t[:] dtindex, int quarters,
int q1start_month, object day, int modby=3):
def shift_quarters(
const int64_t[:] dtindex,
int quarters,
int q1start_month,
object day,
int modby=3,
):
"""
Given an int64 array representing nanosecond timestamps, shift all elements
by the specified number of quarters using DateOffset semantics.
Expand Down Expand Up @@ -759,7 +764,7 @@ def shift_quarters(int64_t[:] dtindex, int quarters,

@cython.wraparound(False)
@cython.boundscheck(False)
def shift_months(int64_t[:] dtindex, int months, object day=None):
def shift_months(const int64_t[:] dtindex, int months, object day=None):
"""
Given an int64-based datetime index, shift all elements
specified number of months using DateOffset semantics
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ _no_input = object()

@cython.boundscheck(False)
@cython.wraparound(False)
def ints_to_pytimedelta(int64_t[:] arr, box=False):
def ints_to_pytimedelta(const int64_t[:] arr, box=False):
"""
convert an i8 repr to an ndarray of timedelta or Timedelta (if box ==
True)
Expand Down
5 changes: 3 additions & 2 deletions pandas/_libs/tslibs/tzconversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,9 @@ cdef int64_t _tz_convert_tzlocal_fromutc(int64_t val, tzinfo tz, bint *fold):

@cython.boundscheck(False)
@cython.wraparound(False)
cdef int64_t[:] _tz_convert_dst(int64_t[:] values, tzinfo tz,
bint to_utc=True):
cdef int64_t[:] _tz_convert_dst(
const int64_t[:] values, tzinfo tz, bint to_utc=True,
):
"""
tz_convert for non-UTC non-tzlocal cases where we have to check
DST transitions pointwise.
Expand Down