Skip to content

Commit

Permalink
Remove unused cimports, fix #22067 (#22087)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and jreback committed Jul 30, 2018
1 parent 9a8cebc commit 26b3e7d
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pandas/_libs/hashing.pyx
Expand Up @@ -3,7 +3,7 @@
# at https://github.com/veorq/SipHash

import cython
cimport numpy as cnp

import numpy as np
from numpy cimport ndarray, uint8_t, uint32_t, uint64_t

Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/frequencies.pyx
Expand Up @@ -2,8 +2,6 @@
# cython: profile=False
import re

cimport cython

cimport numpy as cnp
cnp.import_array()

Expand Down
4 changes: 1 addition & 3 deletions pandas/_libs/tslibs/parsing.pyx
Expand Up @@ -14,9 +14,7 @@ from cpython.datetime cimport datetime
import time

import numpy as np
cimport numpy as cnp
from numpy cimport int64_t, ndarray
cnp.import_array()
from numpy cimport ndarray

# Avoid import from outside _libs
if sys.version_info.major == 2:
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/period.pyx
Expand Up @@ -1920,8 +1920,8 @@ class Period(_Period):
return cls._from_ordinal(ordinal, freq)


cdef int64_t _ordinal_from_fields(year, month, quarter, day,
hour, minute, second, freq):
cdef int64_t _ordinal_from_fields(int year, int month, quarter, int day,
int hour, int minute, int second, freq):
base, mult = get_freq_code(freq)
if quarter is not None:
year, month = quarter_to_myear(year, quarter, freq)
Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/resolution.pyx
Expand Up @@ -5,9 +5,7 @@ cimport cython
from cython cimport Py_ssize_t

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, int64_t, int32_t
cnp.import_array()

from util cimport is_string_object, get_nat

Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/strptime.pyx
Expand Up @@ -25,8 +25,6 @@ import pytz
from cython cimport Py_ssize_t
from cpython cimport PyFloat_Check

cimport cython

import numpy as np
from numpy cimport ndarray, int64_t

Expand Down
10 changes: 5 additions & 5 deletions pandas/_libs/window.pyx
Expand Up @@ -9,7 +9,7 @@ from libc.stdlib cimport malloc, free

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, double_t, int64_t, float64_t
from numpy cimport ndarray, double_t, int64_t, float64_t, float32_t
cnp.import_array()


Expand All @@ -25,11 +25,11 @@ from skiplist cimport (skiplist_t,
skiplist_init, skiplist_destroy,
skiplist_get, skiplist_insert, skiplist_remove)

cdef cnp.float32_t MINfloat32 = np.NINF
cdef cnp.float64_t MINfloat64 = np.NINF
cdef float32_t MINfloat32 = np.NINF
cdef float64_t MINfloat64 = np.NINF

cdef cnp.float32_t MAXfloat32 = np.inf
cdef cnp.float64_t MAXfloat64 = np.inf
cdef float32_t MAXfloat32 = np.inf
cdef float64_t MAXfloat64 = np.inf

cdef double NaN = <double> np.NaN

Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/writers.pyx
Expand Up @@ -12,9 +12,7 @@ except ImportError:
from cpython cimport PyUnicode_GET_SIZE as PyString_GET_SIZE

import numpy as np
cimport numpy as cnp
from numpy cimport ndarray, uint8_t
cnp.import_array()


ctypedef fused pandas_string:
Expand Down
16 changes: 11 additions & 5 deletions pandas/io/msgpack/_packer.pyx
@@ -1,10 +1,16 @@
# coding: utf-8
# cython: embedsignature=True

from cpython cimport *
from libc.stdlib cimport *
from libc.string cimport *
from libc.limits cimport *
from cpython cimport (
PyFloat_Check, PyLong_Check, PyInt_Check,
PyDict_CheckExact, PyDict_Check,
PyTuple_Check, PyList_Check,
PyCallable_Check,
PyUnicode_Check, PyBytes_Check,
PyBytes_AsString,
PyBytes_FromStringAndSize,
PyUnicode_AsEncodedString)
from libc.stdlib cimport free, malloc

from pandas.io.msgpack.exceptions import PackValueError
from pandas.io.msgpack import ExtType
Expand Down Expand Up @@ -74,7 +80,7 @@ cdef class Packer(object):
cdef object _berrors
cdef char *encoding
cdef char *unicode_errors
cdef bool use_float
cdef bint use_float
cdef bint autoreset

def __cinit__(self):
Expand Down
16 changes: 12 additions & 4 deletions pandas/io/msgpack/_unpacker.pyx
@@ -1,15 +1,23 @@
# coding: utf-8
# cython: embedsignature=True

from cpython cimport *
from cython cimport Py_ssize_t

from cpython cimport (
PyCallable_Check,
PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release,
PyBytes_Size,
PyBytes_FromStringAndSize,
PyBytes_AsString)

cdef extern from "Python.h":
ctypedef struct PyObject
cdef int PyObject_AsReadBuffer(object o, const void** buff,
Py_ssize_t* buf_len) except -1

from libc.stdlib cimport *
from libc.string cimport *
from libc.limits cimport *
from libc.stdlib cimport free, malloc
from libc.string cimport memcpy, memmove
from libc.limits cimport INT_MAX

from pandas.io.msgpack.exceptions import (BufferFull, OutOfData,
UnpackValueError, ExtraData)
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/indexes/datetimes/test_datetime.py
@@ -1,4 +1,5 @@
import warnings
import sys

import pytest

Expand Down Expand Up @@ -126,6 +127,16 @@ def test_map(self):
exp = Index([f(x) for x in rng], dtype='<U8')
tm.assert_index_equal(result, exp)

@tm.capture_stderr
def test_map_fallthrough(self):
# GH#22067, check we don't get warnings about silently ignored errors
dti = date_range('2017-01-01', '2018-01-01', freq='B')

dti.map(lambda x: pd.Period(year=x.year, month=x.month, freq='M'))

cv = sys.stderr.getvalue()
assert cv == ''

def test_iteration_preserves_tz(self):
# see gh-8890
index = date_range("2012-01-01", periods=3, freq='H', tz='US/Eastern')
Expand Down

0 comments on commit 26b3e7d

Please sign in to comment.