Skip to content

Commit 26b3e7d

Browse files
jbrockmendeljreback
authored andcommitted
Remove unused cimports, fix #22067 (#22087)
1 parent 9a8cebc commit 26b3e7d

File tree

11 files changed

+43
-28
lines changed

11 files changed

+43
-28
lines changed

pandas/_libs/hashing.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# at https://github.com/veorq/SipHash
44

55
import cython
6-
cimport numpy as cnp
6+
77
import numpy as np
88
from numpy cimport ndarray, uint8_t, uint32_t, uint64_t
99

pandas/_libs/tslibs/frequencies.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# cython: profile=False
33
import re
44

5-
cimport cython
6-
75
cimport numpy as cnp
86
cnp.import_array()
97

pandas/_libs/tslibs/parsing.pyx

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ from cpython.datetime cimport datetime
1414
import time
1515

1616
import numpy as np
17-
cimport numpy as cnp
18-
from numpy cimport int64_t, ndarray
19-
cnp.import_array()
17+
from numpy cimport ndarray
2018

2119
# Avoid import from outside _libs
2220
if sys.version_info.major == 2:

pandas/_libs/tslibs/period.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1920,8 +1920,8 @@ class Period(_Period):
19201920
return cls._from_ordinal(ordinal, freq)
19211921

19221922

1923-
cdef int64_t _ordinal_from_fields(year, month, quarter, day,
1924-
hour, minute, second, freq):
1923+
cdef int64_t _ordinal_from_fields(int year, int month, quarter, int day,
1924+
int hour, int minute, int second, freq):
19251925
base, mult = get_freq_code(freq)
19261926
if quarter is not None:
19271927
year, month = quarter_to_myear(year, quarter, freq)

pandas/_libs/tslibs/resolution.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ cimport cython
55
from cython cimport Py_ssize_t
66

77
import numpy as np
8-
cimport numpy as cnp
98
from numpy cimport ndarray, int64_t, int32_t
10-
cnp.import_array()
119

1210
from util cimport is_string_object, get_nat
1311

pandas/_libs/tslibs/strptime.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import pytz
2525
from cython cimport Py_ssize_t
2626
from cpython cimport PyFloat_Check
2727

28-
cimport cython
29-
3028
import numpy as np
3129
from numpy cimport ndarray, int64_t
3230

pandas/_libs/window.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from libc.stdlib cimport malloc, free
99

1010
import numpy as np
1111
cimport numpy as cnp
12-
from numpy cimport ndarray, double_t, int64_t, float64_t
12+
from numpy cimport ndarray, double_t, int64_t, float64_t, float32_t
1313
cnp.import_array()
1414

1515

@@ -25,11 +25,11 @@ from skiplist cimport (skiplist_t,
2525
skiplist_init, skiplist_destroy,
2626
skiplist_get, skiplist_insert, skiplist_remove)
2727

28-
cdef cnp.float32_t MINfloat32 = np.NINF
29-
cdef cnp.float64_t MINfloat64 = np.NINF
28+
cdef float32_t MINfloat32 = np.NINF
29+
cdef float64_t MINfloat64 = np.NINF
3030

31-
cdef cnp.float32_t MAXfloat32 = np.inf
32-
cdef cnp.float64_t MAXfloat64 = np.inf
31+
cdef float32_t MAXfloat32 = np.inf
32+
cdef float64_t MAXfloat64 = np.inf
3333

3434
cdef double NaN = <double> np.NaN
3535

pandas/_libs/writers.pyx

-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ except ImportError:
1212
from cpython cimport PyUnicode_GET_SIZE as PyString_GET_SIZE
1313

1414
import numpy as np
15-
cimport numpy as cnp
1615
from numpy cimport ndarray, uint8_t
17-
cnp.import_array()
1816

1917

2018
ctypedef fused pandas_string:

pandas/io/msgpack/_packer.pyx

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# coding: utf-8
22
# cython: embedsignature=True
33

4-
from cpython cimport *
5-
from libc.stdlib cimport *
6-
from libc.string cimport *
7-
from libc.limits cimport *
4+
from cpython cimport (
5+
PyFloat_Check, PyLong_Check, PyInt_Check,
6+
PyDict_CheckExact, PyDict_Check,
7+
PyTuple_Check, PyList_Check,
8+
PyCallable_Check,
9+
PyUnicode_Check, PyBytes_Check,
10+
PyBytes_AsString,
11+
PyBytes_FromStringAndSize,
12+
PyUnicode_AsEncodedString)
13+
from libc.stdlib cimport free, malloc
814

915
from pandas.io.msgpack.exceptions import PackValueError
1016
from pandas.io.msgpack import ExtType
@@ -74,7 +80,7 @@ cdef class Packer(object):
7480
cdef object _berrors
7581
cdef char *encoding
7682
cdef char *unicode_errors
77-
cdef bool use_float
83+
cdef bint use_float
7884
cdef bint autoreset
7985

8086
def __cinit__(self):

pandas/io/msgpack/_unpacker.pyx

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
# coding: utf-8
22
# cython: embedsignature=True
33

4-
from cpython cimport *
4+
from cython cimport Py_ssize_t
5+
6+
from cpython cimport (
7+
PyCallable_Check,
8+
PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release,
9+
PyBytes_Size,
10+
PyBytes_FromStringAndSize,
11+
PyBytes_AsString)
12+
513
cdef extern from "Python.h":
614
ctypedef struct PyObject
715
cdef int PyObject_AsReadBuffer(object o, const void** buff,
816
Py_ssize_t* buf_len) except -1
917

10-
from libc.stdlib cimport *
11-
from libc.string cimport *
12-
from libc.limits cimport *
18+
from libc.stdlib cimport free, malloc
19+
from libc.string cimport memcpy, memmove
20+
from libc.limits cimport INT_MAX
1321

1422
from pandas.io.msgpack.exceptions import (BufferFull, OutOfData,
1523
UnpackValueError, ExtraData)

pandas/tests/indexes/datetimes/test_datetime.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import warnings
2+
import sys
23

34
import pytest
45

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

130+
@tm.capture_stderr
131+
def test_map_fallthrough(self):
132+
# GH#22067, check we don't get warnings about silently ignored errors
133+
dti = date_range('2017-01-01', '2018-01-01', freq='B')
134+
135+
dti.map(lambda x: pd.Period(year=x.year, month=x.month, freq='M'))
136+
137+
cv = sys.stderr.getvalue()
138+
assert cv == ''
139+
129140
def test_iteration_preserves_tz(self):
130141
# see gh-8890
131142
index = date_range("2012-01-01", periods=3, freq='H', tz='US/Eastern')

0 commit comments

Comments
 (0)