Skip to content
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

Remove unused from datetime.pxd, check for fastpath in ensure_datetime64ns #18453

Merged
merged 2 commits into from
Nov 24, 2017
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
14 changes: 0 additions & 14 deletions pandas/_libs/src/datetime.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ from cpython cimport PyUnicode_Check, PyUnicode_AsASCIIString


cdef extern from "numpy/ndarrayobject.h":
ctypedef int64_t npy_timedelta
ctypedef int64_t npy_datetime

ctypedef enum NPY_CASTING:
Expand All @@ -15,15 +14,10 @@ cdef extern from "numpy/ndarrayobject.h":
NPY_SAME_KIND_CASTING
NPY_UNSAFE_CASTING

cdef extern from "numpy_helper.h":
npy_datetime get_datetime64_value(object o)
npy_timedelta get_timedelta64_value(object o)

cdef extern from "numpy/npy_common.h":
ctypedef unsigned char npy_bool

cdef extern from "datetime/np_datetime.h":

ctypedef enum PANDAS_DATETIMEUNIT:
PANDAS_FR_Y
PANDAS_FR_M
Expand All @@ -44,20 +38,12 @@ cdef extern from "datetime/np_datetime.h":
npy_int64 year
npy_int32 month, day, hour, min, sec, us, ps, as

npy_datetime pandas_datetimestruct_to_datetime(
PANDAS_DATETIMEUNIT fr, pandas_datetimestruct *d) nogil

void pandas_datetime_to_datetimestruct(npy_datetime val,
PANDAS_DATETIMEUNIT fr,
pandas_datetimestruct *result) nogil
int days_per_month_table[2][12]

int dayofweek(int y, int m, int d) nogil
int is_leapyear(int64_t year) nogil
PANDAS_DATETIMEUNIT get_datetime64_unit(object o)

cdef extern from "datetime/np_datetime_strings.h":

int parse_iso_8601_datetime(char *str, int len, PANDAS_DATETIMEUNIT unit,
NPY_CASTING casting,
pandas_datetimestruct *out,
Expand Down
8 changes: 0 additions & 8 deletions pandas/_libs/src/numpy_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ The full license is in the LICENSE file, distributed with this software.

PANDAS_INLINE npy_int64 get_nat(void) { return NPY_MIN_INT64; }

PANDAS_INLINE npy_datetime get_datetime64_value(PyObject* obj) {
return ((PyDatetimeScalarObject*)obj)->obval;
}

PANDAS_INLINE npy_timedelta get_timedelta64_value(PyObject* obj) {
return ((PyTimedeltaScalarObject*)obj)->obval;
}

PANDAS_INLINE int is_integer_object(PyObject* obj) {
return (!PyBool_Check(obj)) && PyArray_IsIntegerScalar(obj);
}
Expand Down
17 changes: 10 additions & 7 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,16 @@ def ensure_datetime64ns(ndarray arr):
return result

unit = get_datetime64_unit(arr.flat[0])
for i in range(n):
if ivalues[i] != NPY_NAT:
pandas_datetime_to_datetimestruct(ivalues[i], unit, &dts)
iresult[i] = dtstruct_to_dt64(&dts)
check_dts_bounds(&dts)
else:
iresult[i] = NPY_NAT
if unit == PANDAS_FR_ns:
result = arr
else:
for i in range(n):
if ivalues[i] != NPY_NAT:
pandas_datetime_to_datetimestruct(ivalues[i], unit, &dts)
iresult[i] = dtstruct_to_dt64(&dts)
check_dts_bounds(&dts)
else:
iresult[i] = NPY_NAT

return result

Expand Down