Skip to content

cleanup unused imports, constants #18119

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 5 commits into from
Nov 7, 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
24 changes: 9 additions & 15 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -52,23 +54,15 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont' really like this but i guess its how it is currently. this is a python level dep between lib and tslib.

Copy link
Member Author

Choose a reason for hiding this comment

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

Timestamp and Timedelta aren't used in lib. A couple of modules use lib.Timestamp instead of tslib.Timestamp. The NaT dependency could be imported directly from tslibs.nattype. array_to_datetime... not really any good options.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, just mentioning it

from interval import Interval

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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pandas/_libs/properties.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from cython cimport Py_ssize_t

Expand Down
6 changes: 0 additions & 6 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

Expand All @@ -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":
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pandas/_libs/src/reduce.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down