Skip to content

Commit 537e880

Browse files
jbrockmendeljreback
authored andcommitted
cleanup unused imports, constants (pandas-dev#18119)
1 parent d7c04fb commit 537e880

File tree

5 files changed

+13
-25
lines changed

5 files changed

+13
-25
lines changed

pandas/_libs/lib.pyx

+9-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ cdef bint PY3 = (sys.version_info[0] >= 3)
88

99
from numpy cimport *
1010

11+
# initialize numpy
1112
np.import_array()
13+
np.import_ufunc()
1214

1315
from libc.stdlib cimport malloc, free
1416

@@ -52,23 +54,15 @@ PyDateTime_IMPORT
5254
from tslibs.np_datetime cimport get_timedelta64_value, get_datetime64_value
5355

5456
from tslib cimport _check_all_nulls
55-
import tslib
56-
from tslib import NaT, Timestamp, Timedelta
57-
import interval
57+
from tslib import NaT, Timestamp, Timedelta, array_to_datetime
5858
from interval import Interval
5959

6060
cdef int64_t NPY_NAT = util.get_nat()
6161

6262
cimport util
6363
from util cimport is_array, _checknull, _checknan
6464

65-
cdef extern from "math.h":
66-
double sqrt(double x)
67-
double fabs(double)
68-
69-
# initialize numpy
70-
import_array()
71-
import_ufunc()
65+
from libc.math cimport sqrt, fabs
7266

7367

7468
def values_from_object(object o):
@@ -151,7 +145,7 @@ cpdef bint checknull_old(object val):
151145
elif is_array(val):
152146
return False
153147
else:
154-
return util._checknull(val)
148+
return _checknull(val)
155149

156150

157151
cpdef bint isposinf_scalar(object val):
@@ -787,13 +781,13 @@ def scalar_binop(ndarray[object] values, object val, object op):
787781
object x
788782

789783
result = np.empty(n, dtype=object)
790-
if util._checknull(val):
784+
if _checknull(val):
791785
result.fill(val)
792786
return result
793787

794788
for i in range(n):
795789
x = values[i]
796-
if util._checknull(x):
790+
if _checknull(x):
797791
result[i] = x
798792
else:
799793
result[i] = op(x, val)
@@ -820,9 +814,9 @@ def vec_binop(ndarray[object] left, ndarray[object] right, object op):
820814
try:
821815
result[i] = op(x, y)
822816
except TypeError:
823-
if util._checknull(x):
817+
if _checknull(x):
824818
result[i] = x
825-
elif util._checknull(y):
819+
elif _checknull(y):
826820
result[i] = y
827821
else:
828822
raise

pandas/_libs/properties.pyx

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12

23
from cython cimport Py_ssize_t
34

pandas/_libs/src/datetime.pxd

-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ from cpython cimport PyUnicode_Check, PyUnicode_AsASCIIString
55

66

77
cdef extern from "numpy/ndarrayobject.h":
8-
98
ctypedef int64_t npy_timedelta
109
ctypedef int64_t npy_datetime
1110

@@ -16,13 +15,11 @@ cdef extern from "numpy/ndarrayobject.h":
1615
NPY_SAME_KIND_CASTING
1716
NPY_UNSAFE_CASTING
1817

19-
2018
cdef extern from "numpy_helper.h":
2119
npy_datetime get_datetime64_value(object o)
2220
npy_timedelta get_timedelta64_value(object o)
2321

2422
cdef extern from "numpy/npy_common.h":
25-
2623
ctypedef unsigned char npy_bool
2724

2825
cdef extern from "datetime/np_datetime.h":
@@ -53,7 +50,6 @@ cdef extern from "datetime/np_datetime.h":
5350
PANDAS_DATETIMEUNIT fr,
5451
pandas_datetimestruct *result) nogil
5552
int days_per_month_table[2][12]
56-
pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS
5753

5854
int dayofweek(int y, int m, int d) nogil
5955
int is_leapyear(int64_t year) nogil
@@ -68,8 +64,6 @@ cdef extern from "datetime/np_datetime_strings.h":
6864
npy_bool *out_special)
6965

7066

71-
72-
7367
cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts,
7468
int* out_local, int* out_tzoffset) except? -1:
7569
cdef int result

pandas/_libs/src/inference.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ cpdef object infer_datetimelike_array(object arr):
521521
# convert *every* string array
522522
if len(objs):
523523
try:
524-
tslib.array_to_datetime(objs, errors='raise')
524+
array_to_datetime(objs, errors='raise')
525525
return 'datetime'
526526
except:
527527
pass

pandas/_libs/src/reduce.pyx

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ from distutils.version import LooseVersion
66

77
is_numpy_prior_1_6_2 = LooseVersion(np.__version__) < '1.6.2'
88

9-
cdef _get_result_array(object obj,
10-
Py_ssize_t size,
11-
Py_ssize_t cnt):
9+
10+
cdef _get_result_array(object obj, Py_ssize_t size, Py_ssize_t cnt):
1211

1312
if isinstance(obj, np.ndarray) \
1413
or isinstance(obj, list) and len(obj) == cnt \

0 commit comments

Comments
 (0)