Skip to content

update imports; remove unused #18298

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 1 commit into from
Nov 17, 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
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 @@ -203,7 +202,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 @@ -238,9 +237,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 Down Expand Up @@ -57,7 +55,6 @@ from tslibs.np_datetime cimport (check_dts_bounds,
pandas_datetimestruct,
dt64_to_dtstruct, dtstruct_to_dt64,
pydatetime_to_dt64, pydate_to_dt64,
npy_datetime,
get_datetime64_unit, get_datetime64_value,
get_timedelta64_value)
from tslibs.np_datetime import OutOfBoundsDatetime
Expand All @@ -82,12 +79,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)
Copy link
Contributor

Choose a reason for hiding this comment

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

build_field_sarray I think can be completely removed from the codebase

Copy link
Member Author

Choose a reason for hiding this comment

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

It's used in tslibs.resolution.

There are a few funcs scattered around _libs that aren't used anywhere. Didn't remove them in this PR to keep it uncontroversial. lib.arrmap and index.get_value_at come to mind.

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 @@ -1744,13 +1739,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