Skip to content

Commit aeb9040

Browse files
authored
CLN/STY: Nitpicks (#32961)
1 parent 0cf3491 commit aeb9040

File tree

6 files changed

+77
-24
lines changed

6 files changed

+77
-24
lines changed

pandas/_libs/algos.pyx

+30-9
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ cimport pandas._libs.util as util
3838
from pandas._libs.util cimport numeric, get_nat
3939

4040
from pandas._libs.khash cimport (
41-
khiter_t, kh_destroy_int64, kh_put_int64, kh_init_int64, kh_int64_t,
42-
kh_resize_int64, kh_get_int64)
41+
kh_destroy_int64,
42+
kh_get_int64,
43+
kh_init_int64,
44+
kh_int64_t,
45+
kh_put_int64,
46+
kh_resize_int64,
47+
khiter_t,
48+
)
49+
4350

4451
import pandas._libs.missing as missing
4552

@@ -791,8 +798,13 @@ ctypedef fused rank_t:
791798

792799
@cython.wraparound(False)
793800
@cython.boundscheck(False)
794-
def rank_1d(rank_t[:] in_arr, ties_method='average',
795-
ascending=True, na_option='keep', pct=False):
801+
def rank_1d(
802+
rank_t[:] in_arr,
803+
ties_method="average",
804+
bint ascending=True,
805+
na_option="keep",
806+
bint pct=False,
807+
):
796808
"""
797809
Fast NaN-friendly version of ``scipy.stats.rankdata``.
798810
"""
@@ -1009,8 +1021,14 @@ def rank_1d(rank_t[:] in_arr, ties_method='average',
10091021
return ranks
10101022

10111023

1012-
def rank_2d(rank_t[:, :] in_arr, axis=0, ties_method='average',
1013-
ascending=True, na_option='keep', pct=False):
1024+
def rank_2d(
1025+
rank_t[:, :] in_arr,
1026+
int axis=0,
1027+
ties_method="average",
1028+
bint ascending=True,
1029+
na_option="keep",
1030+
bint pct=False,
1031+
):
10141032
"""
10151033
Fast NaN-friendly version of ``scipy.stats.rankdata``.
10161034
"""
@@ -1190,9 +1208,12 @@ ctypedef fused out_t:
11901208

11911209
@cython.boundscheck(False)
11921210
@cython.wraparound(False)
1193-
def diff_2d(diff_t[:, :] arr,
1194-
out_t[:, :] out,
1195-
Py_ssize_t periods, int axis):
1211+
def diff_2d(
1212+
diff_t[:, :] arr,
1213+
out_t[:, :] out,
1214+
Py_ssize_t periods,
1215+
int axis,
1216+
):
11961217
cdef:
11971218
Py_ssize_t i, j, sx, sy, start, stop
11981219
bint f_contig = arr.is_f_contig()

pandas/_libs/index.pyx

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ import warnings
22

33
import numpy as np
44
cimport numpy as cnp
5-
from numpy cimport (ndarray, intp_t,
6-
float64_t, float32_t,
7-
int64_t, int32_t, int16_t, int8_t,
8-
uint64_t, uint32_t, uint16_t, uint8_t
5+
from numpy cimport (
6+
float32_t,
7+
float64_t,
8+
int8_t,
9+
int16_t,
10+
int32_t,
11+
int64_t,
12+
intp_t,
13+
ndarray,
14+
uint8_t,
15+
uint16_t,
16+
uint32_t,
17+
uint64_t,
918
)
1019
cnp.import_array()
1120

@@ -364,7 +373,7 @@ cdef class ObjectEngine(IndexEngine):
364373

365374
cdef class DatetimeEngine(Int64Engine):
366375

367-
cdef _get_box_dtype(self):
376+
cdef str _get_box_dtype(self):
368377
return 'M8[ns]'
369378

370379
cdef int64_t _unbox_scalar(self, scalar) except? -1:
@@ -454,7 +463,7 @@ cdef class DatetimeEngine(Int64Engine):
454463

455464
cdef class TimedeltaEngine(DatetimeEngine):
456465

457-
cdef _get_box_dtype(self):
466+
cdef str _get_box_dtype(self):
458467
return 'm8[ns]'
459468

460469
cdef int64_t _unbox_scalar(self, scalar) except? -1:

pandas/_libs/indexing.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ cdef class _NDFrameIndexerBase:
22
"""
33
A base class for _NDFrameIndexer for fast instantiation and attribute access.
44
"""
5-
cdef public object obj, name, _ndim
5+
cdef public:
6+
object obj, name, _ndim
67

78
def __init__(self, name, obj):
89
self.obj = obj

pandas/_libs/interval.pyx

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
import numbers
22
from operator import le, lt
33

4-
from cpython.object cimport (Py_EQ, Py_NE, Py_GT, Py_LT, Py_GE, Py_LE,
5-
PyObject_RichCompare)
4+
from cpython.object cimport (
5+
Py_EQ,
6+
Py_GE,
7+
Py_GT,
8+
Py_LE,
9+
Py_LT,
10+
Py_NE,
11+
PyObject_RichCompare,
12+
)
13+
614

715
import cython
816
from cython import Py_ssize_t
917

1018
import numpy as np
1119
cimport numpy as cnp
1220
from numpy cimport (
13-
int64_t, int32_t, float64_t, float32_t, uint64_t,
21+
NPY_QUICKSORT,
22+
PyArray_ArgSort,
23+
PyArray_Take,
24+
float32_t,
25+
float64_t,
26+
int32_t,
27+
int64_t,
1428
ndarray,
15-
PyArray_ArgSort, NPY_QUICKSORT, PyArray_Take)
29+
uint64_t,
30+
)
1631
cnp.import_array()
1732

1833

pandas/_libs/ops.pyx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import operator
22

3-
from cpython.object cimport (PyObject_RichCompareBool,
4-
Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE)
3+
from cpython.object cimport (
4+
Py_EQ,
5+
Py_GE,
6+
Py_GT,
7+
Py_LE,
8+
Py_LT,
9+
Py_NE,
10+
PyObject_RichCompareBool,
11+
)
12+
513

614
import cython
715
from cython import Py_ssize_t

pandas/_libs/properties.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from cython import Py_ssize_t
22

3-
from cpython.dict cimport (
4-
PyDict_Contains, PyDict_GetItem, PyDict_SetItem)
3+
from cpython.dict cimport PyDict_Contains, PyDict_GetItem, PyDict_SetItem
54

65

76
cdef class CachedProperty:

0 commit comments

Comments
 (0)