diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index d012e169d1e45..c8c5f86820b76 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -8,7 +8,9 @@ cdef bint PY3 = (sys.version_info[0] >= 3) from numpy cimport * +# initialize numpy np.import_array() +np.import_ufunc() from libc.stdlib cimport malloc, free @@ -52,9 +54,7 @@ PyDateTime_IMPORT from tslibs.np_datetime cimport get_timedelta64_value, get_datetime64_value from tslib cimport _check_all_nulls -import tslib -from tslib import NaT, Timestamp, Timedelta -import interval +from tslib import NaT, Timestamp, Timedelta, array_to_datetime from interval import Interval cdef int64_t NPY_NAT = util.get_nat() @@ -62,13 +62,7 @@ cdef int64_t NPY_NAT = util.get_nat() cimport util from util cimport is_array, _checknull, _checknan -cdef extern from "math.h": - double sqrt(double x) - double fabs(double) - -# initialize numpy -import_array() -import_ufunc() +from libc.math cimport sqrt, fabs def values_from_object(object o): @@ -151,7 +145,7 @@ cpdef bint checknull_old(object val): elif is_array(val): return False else: - return util._checknull(val) + return _checknull(val) cpdef bint isposinf_scalar(object val): @@ -787,13 +781,13 @@ def scalar_binop(ndarray[object] values, object val, object op): object x result = np.empty(n, dtype=object) - if util._checknull(val): + if _checknull(val): result.fill(val) return result for i in range(n): x = values[i] - if util._checknull(x): + if _checknull(x): result[i] = x else: result[i] = op(x, val) @@ -820,9 +814,9 @@ def vec_binop(ndarray[object] left, ndarray[object] right, object op): try: result[i] = op(x, y) except TypeError: - if util._checknull(x): + if _checknull(x): result[i] = x - elif util._checknull(y): + elif _checknull(y): result[i] = y else: raise diff --git a/pandas/_libs/properties.pyx b/pandas/_libs/properties.pyx index 22d66356ebdc3..374da8067eedd 100644 --- a/pandas/_libs/properties.pyx +++ b/pandas/_libs/properties.pyx @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from cython cimport Py_ssize_t diff --git a/pandas/_libs/src/datetime.pxd b/pandas/_libs/src/datetime.pxd index ac975a3bf3537..a5ba610dc89dc 100644 --- a/pandas/_libs/src/datetime.pxd +++ b/pandas/_libs/src/datetime.pxd @@ -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 @@ -16,13 +15,11 @@ 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": @@ -53,7 +50,6 @@ cdef extern from "datetime/np_datetime.h": PANDAS_DATETIMEUNIT fr, pandas_datetimestruct *result) nogil int days_per_month_table[2][12] - pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS int dayofweek(int y, int m, int d) nogil int is_leapyear(int64_t year) nogil @@ -68,8 +64,6 @@ cdef extern from "datetime/np_datetime_strings.h": npy_bool *out_special) - - cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts, int* out_local, int* out_tzoffset) except? -1: cdef int result diff --git a/pandas/_libs/src/inference.pyx b/pandas/_libs/src/inference.pyx index 5d550148b10bc..ec060335c220e 100644 --- a/pandas/_libs/src/inference.pyx +++ b/pandas/_libs/src/inference.pyx @@ -521,7 +521,7 @@ cpdef object infer_datetimelike_array(object arr): # convert *every* string array if len(objs): try: - tslib.array_to_datetime(objs, errors='raise') + array_to_datetime(objs, errors='raise') return 'datetime' except: pass diff --git a/pandas/_libs/src/reduce.pyx b/pandas/_libs/src/reduce.pyx index d1761384114ef..f0ec8d284ef0e 100644 --- a/pandas/_libs/src/reduce.pyx +++ b/pandas/_libs/src/reduce.pyx @@ -6,9 +6,8 @@ from distutils.version import LooseVersion is_numpy_prior_1_6_2 = LooseVersion(np.__version__) < '1.6.2' -cdef _get_result_array(object obj, - Py_ssize_t size, - Py_ssize_t cnt): + +cdef _get_result_array(object obj, Py_ssize_t size, Py_ssize_t cnt): if isinstance(obj, np.ndarray) \ or isinstance(obj, list) and len(obj) == cnt \