Skip to content

Commit 6dc589b

Browse files
authored
CLN, STYLE: remove unused variables and imports in Cython files (#48290)
* remove unused variables and imports * wip * bump to 0.1.4
1 parent b8ae9bb commit 6dc589b

23 files changed

+20
-102
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ repos:
2626
hooks:
2727
- id: codespell
2828
types_or: [python, rst, markdown]
29+
- repo: https://github.com/MarcoGorelli/cython-lint
30+
rev: v0.1.4
31+
hooks:
32+
- id: cython-lint
2933
- repo: https://github.com/pre-commit/pre-commit-hooks
3034
rev: v4.3.0
3135
hooks:

pandas/_libs/algos.pyx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,12 @@ import numpy as np
1414

1515
cimport numpy as cnp
1616
from numpy cimport (
17-
NPY_COMPLEX64,
18-
NPY_COMPLEX128,
19-
NPY_FLOAT32,
2017
NPY_FLOAT64,
2118
NPY_INT8,
2219
NPY_INT16,
2320
NPY_INT32,
2421
NPY_INT64,
2522
NPY_OBJECT,
26-
NPY_UINT8,
27-
NPY_UINT16,
28-
NPY_UINT32,
2923
NPY_UINT64,
3024
float32_t,
3125
float64_t,

pandas/_libs/groupby.pyx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@ from numpy cimport (
1717
float32_t,
1818
float64_t,
1919
int8_t,
20-
int16_t,
21-
int32_t,
2220
int64_t,
2321
intp_t,
2422
ndarray,
2523
uint8_t,
26-
uint16_t,
27-
uint32_t,
2824
uint64_t,
2925
)
3026
from numpy.math cimport NAN
@@ -38,7 +34,6 @@ from pandas._libs.algos cimport (
3834
)
3935

4036
from pandas._libs.algos import (
41-
ensure_platform_int,
4237
groupsort_indexer,
4338
rank_1d,
4439
take_2d_axis1_bool_bool,

pandas/_libs/hashing.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ from numpy cimport (
1313
import_array,
1414
ndarray,
1515
uint8_t,
16-
uint32_t,
1716
uint64_t,
1817
)
1918

@@ -158,7 +157,6 @@ cdef uint64_t low_level_siphash(uint8_t* data, size_t datalen,
158157
cdef int i
159158
cdef uint8_t* end = data + datalen - (datalen % sizeof(uint64_t))
160159
cdef int left = datalen & 7
161-
cdef int left_byte
162160
cdef int cROUNDS = 2
163161
cdef int dROUNDS = 4
164162

pandas/_libs/hashtable.pyx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ from libc.stdlib cimport (
1515
import numpy as np
1616

1717
cimport numpy as cnp
18-
from numpy cimport (
19-
float64_t,
20-
ndarray,
21-
uint8_t,
22-
uint32_t,
23-
)
24-
from numpy.math cimport NAN
18+
from numpy cimport ndarray
2519

2620
cnp.import_array()
2721

@@ -37,9 +31,6 @@ from pandas._libs.khash cimport (
3731
kh_needed_n_buckets,
3832
kh_python_hash_equal,
3933
kh_python_hash_func,
40-
kh_str_t,
41-
khcomplex64_t,
42-
khcomplex128_t,
4334
khiter_t,
4435
)
4536
from pandas._libs.missing cimport checknull

pandas/_libs/index.pyx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@ import numpy as np
44

55
cimport numpy as cnp
66
from numpy cimport (
7-
float32_t,
8-
float64_t,
9-
int8_t,
10-
int16_t,
11-
int32_t,
127
int64_t,
138
intp_t,
149
ndarray,
1510
uint8_t,
16-
uint16_t,
17-
uint32_t,
1811
uint64_t,
1912
)
2013

@@ -35,7 +28,6 @@ from pandas._libs import (
3528

3629
from pandas._libs.lib cimport eq_NA_compat
3730
from pandas._libs.missing cimport (
38-
C_NA as NA,
3931
checknull,
4032
is_matching_na,
4133
)

pandas/_libs/internals.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ cdef class BlockPlacement:
226226
"""
227227
cdef:
228228
slice nv, s = self._ensure_has_slice()
229-
Py_ssize_t other_int, start, stop, step
229+
Py_ssize_t start, stop, step
230230
ndarray[intp_t, ndim=1] newarr
231231

232232
if s is not None:

pandas/_libs/interval.pyx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import inspect
21
import numbers
32
from operator import (
43
le,
@@ -13,15 +12,7 @@ from cpython.datetime cimport (
1312
import_datetime()
1413

1514
cimport cython
16-
from cpython.object cimport (
17-
Py_EQ,
18-
Py_GE,
19-
Py_GT,
20-
Py_LE,
21-
Py_LT,
22-
Py_NE,
23-
PyObject_RichCompare,
24-
)
15+
from cpython.object cimport PyObject_RichCompare
2516
from cython cimport Py_ssize_t
2617

2718
import numpy as np
@@ -31,9 +22,7 @@ from numpy cimport (
3122
NPY_QUICKSORT,
3223
PyArray_ArgSort,
3324
PyArray_Take,
34-
float32_t,
3525
float64_t,
36-
int32_t,
3726
int64_t,
3827
ndarray,
3928
uint64_t,

pandas/_libs/lib.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ from numpy cimport (
4747
PyArray_IterNew,
4848
complex128_t,
4949
flatiter,
50-
float32_t,
5150
float64_t,
5251
int64_t,
5352
intp_t,

pandas/_libs/sparse.pyx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import numpy as np
33

44
cimport numpy as cnp
55
from numpy cimport (
6-
float32_t,
76
float64_t,
87
int8_t,
9-
int16_t,
108
int32_t,
119
int64_t,
1210
ndarray,
@@ -127,7 +125,7 @@ cdef class IntIndex(SparseIndex):
127125

128126
cpdef IntIndex intersect(self, SparseIndex y_):
129127
cdef:
130-
Py_ssize_t out_length, xi, yi = 0, result_indexer = 0
128+
Py_ssize_t xi, yi = 0, result_indexer = 0
131129
int32_t xind
132130
ndarray[int32_t, ndim=1] xindices, yindices, new_indices
133131
IntIndex y
@@ -205,7 +203,7 @@ cdef class IntIndex(SparseIndex):
205203
Vectorized lookup, returns ndarray[int32_t]
206204
"""
207205
cdef:
208-
Py_ssize_t n, i, ind_val
206+
Py_ssize_t n
209207
ndarray[int32_t, ndim=1] inds
210208
ndarray[uint8_t, ndim=1, cast=True] mask
211209
ndarray[int32_t, ndim=1] masked
@@ -232,7 +230,7 @@ cdef class IntIndex(SparseIndex):
232230

233231
cpdef get_blocks(ndarray[int32_t, ndim=1] indices):
234232
cdef:
235-
Py_ssize_t init_len, i, npoints, result_indexer = 0
233+
Py_ssize_t i, npoints, result_indexer = 0
236234
int32_t block, length = 1, cur, prev
237235
ndarray[int32_t, ndim=1] locs, lens
238236

@@ -606,7 +604,7 @@ cdef class BlockUnion(BlockMerge):
606604
cdef:
607605
ndarray[int32_t, ndim=1] xstart, xend, ystart
608606
ndarray[int32_t, ndim=1] yend, out_bloc, out_blen
609-
int32_t nstart, nend, diff
607+
int32_t nstart, nend
610608
Py_ssize_t max_len, result_indexer = 0
611609

612610
xstart = self.xstart
@@ -659,7 +657,7 @@ cdef class BlockUnion(BlockMerge):
659657
"""
660658
cdef:
661659
ndarray[int32_t, ndim=1] xstart, xend, ystart, yend
662-
int32_t xi, yi, xnblocks, ynblocks, nend
660+
int32_t xi, yi, ynblocks, nend
663661

664662
if mode != 0 and mode != 1:
665663
raise Exception('Mode must be 0 or 1')

0 commit comments

Comments
 (0)