Skip to content

Commit

Permalink
update imports; remove unused (pandas-dev#18298)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and jreback committed Nov 17, 2017
1 parent c1406a3 commit d5c4908
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
5 changes: 1 addition & 4 deletions pandas/_libs/index.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ from pandas._libs.tslib import Timestamp, Timedelta
from datetime import datetime, timedelta, date

from cpython cimport PyTuple_Check, PyList_Check
from cpython.slice cimport PySlice_Check

cdef int64_t iNaT = util.get_nat()


cdef extern from "Python.h":
int PySlice_Check(object)


cdef inline is_definitely_invalid_key(object val):
if PyTuple_Check(val):
try:
Expand Down
6 changes: 1 addition & 5 deletions pandas/_libs/period.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# cython: profile=False
from datetime import datetime, date, timedelta
import operator

from cpython cimport (
PyUnicode_Check,
Expand Down Expand Up @@ -201,7 +200,7 @@ def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end):
Py_ssize_t i, n
freq_conv_func func
asfreq_info finfo
int64_t val, ordinal
int64_t val
char relation

n = len(arr)
Expand Down Expand Up @@ -236,9 +235,6 @@ def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end):

def period_ordinal(int y, int m, int d, int h, int min,
int s, int us, int ps, int freq):
cdef:
int64_t ordinal

return get_period_ordinal(y, m, d, h, min, s, us, ps, freq)


Expand Down
20 changes: 4 additions & 16 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# distutils: define_macros=CYTHON_TRACE_NOGIL=0

cimport numpy as np
from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray,
from numpy cimport (int32_t, int64_t, import_array, ndarray,
float64_t, NPY_DATETIME, NPY_TIMEDELTA)
import numpy as np

Expand All @@ -24,8 +24,6 @@ from cpython cimport (
cdef extern from "Python.h":
cdef PyTypeObject *Py_TYPE(object)

from libc.stdlib cimport free

from util cimport (is_integer_object, is_float_object, is_string_object,
is_datetime64_object, is_timedelta64_object,
INT64_MAX)
Expand All @@ -51,7 +49,6 @@ from tslibs.np_datetime cimport (check_dts_bounds,
PANDAS_DATETIMEUNIT, PANDAS_FR_ns,
dt64_to_dtstruct, dtstruct_to_dt64,
pydatetime_to_dt64, pydate_to_dt64,
npy_datetime,
get_datetime64_unit, get_datetime64_value,
get_timedelta64_value,
days_per_month_table,
Expand All @@ -75,12 +72,10 @@ from tslibs.timedeltas cimport cast_from_unit, delta_to_nanoseconds
from tslibs.timedeltas import Timedelta
from tslibs.timezones cimport (
is_utc, is_tzlocal, is_fixed_offset,
treat_tz_as_dateutil, treat_tz_as_pytz,
get_timezone, get_utcoffset, maybe_get_tz,
treat_tz_as_pytz,
get_timezone, maybe_get_tz,
get_dst_info)
from tslibs.fields import (
get_date_name_field, get_start_end_field, get_date_field,
build_field_sarray)
from tslibs.fields import get_start_end_field, get_date_field
from tslibs.conversion cimport (tz_convert_single, _TSObject,
convert_to_tsobject,
convert_datetime_to_tsobject,
Expand Down Expand Up @@ -1763,13 +1758,6 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
return oresult


cdef PyTypeObject* td_type = <PyTypeObject*> Timedelta


cdef inline bint is_timedelta(object o):
return Py_TYPE(o) == td_type # isinstance(o, Timedelta)


# ----------------------------------------------------------------------
# Conversion routines

Expand Down
12 changes: 6 additions & 6 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from pandas._libs import (lib, index as libindex, tslib as libts,
algos as libalgos, join as libjoin,
Timestamp, period as libperiod)
from pandas._libs.tslibs import timezones, conversion
from pandas._libs.tslibs import timezones, conversion, fields

# -------- some conversion wrapper functions

Expand All @@ -75,20 +75,20 @@ def f(self):
self.freq.kwds.get('month', 12))
if self.freq else 12)

result = libts.get_start_end_field(values, field, self.freqstr,
month_kw)
result = fields.get_start_end_field(values, field,
self.freqstr, month_kw)
else:
result = libts.get_date_field(values, field)
result = fields.get_date_field(values, field)

# these return a boolean by-definition
return result

if field in self._object_ops:
result = libts.get_date_name_field(values, field)
result = fields.get_date_name_field(values, field)
result = self._maybe_mask_results(result)

else:
result = libts.get_date_field(values, field)
result = fields.get_date_field(values, field)
result = self._maybe_mask_results(result, convert='float64')

return Index(result, name=self.name)
Expand Down

0 comments on commit d5c4908

Please sign in to comment.