Skip to content

Commit d5c4908

Browse files
jbrockmendeljreback
authored andcommitted
update imports; remove unused (pandas-dev#18298)
1 parent c1406a3 commit d5c4908

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

pandas/_libs/index.pyx

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ from pandas._libs.tslib import Timestamp, Timedelta
2222
from datetime import datetime, timedelta, date
2323

2424
from cpython cimport PyTuple_Check, PyList_Check
25+
from cpython.slice cimport PySlice_Check
2526

2627
cdef int64_t iNaT = util.get_nat()
2728

2829

29-
cdef extern from "Python.h":
30-
int PySlice_Check(object)
31-
32-
3330
cdef inline is_definitely_invalid_key(object val):
3431
if PyTuple_Check(val):
3532
try:

pandas/_libs/period.pyx

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# cython: profile=False
33
from datetime import datetime, date, timedelta
4-
import operator
54

65
from cpython cimport (
76
PyUnicode_Check,
@@ -201,7 +200,7 @@ def period_asfreq_arr(ndarray[int64_t] arr, int freq1, int freq2, bint end):
201200
Py_ssize_t i, n
202201
freq_conv_func func
203202
asfreq_info finfo
204-
int64_t val, ordinal
203+
int64_t val
205204
char relation
206205

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

237236
def period_ordinal(int y, int m, int d, int h, int min,
238237
int s, int us, int ps, int freq):
239-
cdef:
240-
int64_t ordinal
241-
242238
return get_period_ordinal(y, m, d, h, min, s, us, ps, freq)
243239

244240

pandas/_libs/tslib.pyx

+4-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# distutils: define_macros=CYTHON_TRACE_NOGIL=0
66

77
cimport numpy as np
8-
from numpy cimport (int8_t, int32_t, int64_t, import_array, ndarray,
8+
from numpy cimport (int32_t, int64_t, import_array, ndarray,
99
float64_t, NPY_DATETIME, NPY_TIMEDELTA)
1010
import numpy as np
1111

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

27-
from libc.stdlib cimport free
28-
2927
from util cimport (is_integer_object, is_float_object, is_string_object,
3028
is_datetime64_object, is_timedelta64_object,
3129
INT64_MAX)
@@ -51,7 +49,6 @@ from tslibs.np_datetime cimport (check_dts_bounds,
5149
PANDAS_DATETIMEUNIT, PANDAS_FR_ns,
5250
dt64_to_dtstruct, dtstruct_to_dt64,
5351
pydatetime_to_dt64, pydate_to_dt64,
54-
npy_datetime,
5552
get_datetime64_unit, get_datetime64_value,
5653
get_timedelta64_value,
5754
days_per_month_table,
@@ -75,12 +72,10 @@ from tslibs.timedeltas cimport cast_from_unit, delta_to_nanoseconds
7572
from tslibs.timedeltas import Timedelta
7673
from tslibs.timezones cimport (
7774
is_utc, is_tzlocal, is_fixed_offset,
78-
treat_tz_as_dateutil, treat_tz_as_pytz,
79-
get_timezone, get_utcoffset, maybe_get_tz,
75+
treat_tz_as_pytz,
76+
get_timezone, maybe_get_tz,
8077
get_dst_info)
81-
from tslibs.fields import (
82-
get_date_name_field, get_start_end_field, get_date_field,
83-
build_field_sarray)
78+
from tslibs.fields import get_start_end_field, get_date_field
8479
from tslibs.conversion cimport (tz_convert_single, _TSObject,
8580
convert_to_tsobject,
8681
convert_datetime_to_tsobject,
@@ -1763,13 +1758,6 @@ cpdef array_to_datetime(ndarray[object] values, errors='raise',
17631758
return oresult
17641759

17651760

1766-
cdef PyTypeObject* td_type = <PyTypeObject*> Timedelta
1767-
1768-
1769-
cdef inline bint is_timedelta(object o):
1770-
return Py_TYPE(o) == td_type # isinstance(o, Timedelta)
1771-
1772-
17731761
# ----------------------------------------------------------------------
17741762
# Conversion routines
17751763

pandas/core/indexes/datetimes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from pandas._libs import (lib, index as libindex, tslib as libts,
5656
algos as libalgos, join as libjoin,
5757
Timestamp, period as libperiod)
58-
from pandas._libs.tslibs import timezones, conversion
58+
from pandas._libs.tslibs import timezones, conversion, fields
5959

6060
# -------- some conversion wrapper functions
6161

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

78-
result = libts.get_start_end_field(values, field, self.freqstr,
79-
month_kw)
78+
result = fields.get_start_end_field(values, field,
79+
self.freqstr, month_kw)
8080
else:
81-
result = libts.get_date_field(values, field)
81+
result = fields.get_date_field(values, field)
8282

8383
# these return a boolean by-definition
8484
return result
8585

8686
if field in self._object_ops:
87-
result = libts.get_date_name_field(values, field)
87+
result = fields.get_date_name_field(values, field)
8888
result = self._maybe_mask_results(result)
8989

9090
else:
91-
result = libts.get_date_field(values, field)
91+
result = fields.get_date_field(values, field)
9292
result = self._maybe_mask_results(result, convert='float64')
9393

9494
return Index(result, name=self.name)

0 commit comments

Comments
 (0)