Skip to content

Commit f1f5dcd

Browse files
author
MomIsBestFriend
committed
CLN: some code cleanups
1 parent 80d37ad commit f1f5dcd

File tree

8 files changed

+155
-100
lines changed

8 files changed

+155
-100
lines changed

pandas/_libs/hashtable.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ cdef class Factorizer:
8686
self, ndarray[object] values, sort=False, na_sentinel=-1, na_value=None
8787
):
8888
"""
89+
Examples
90+
--------
8991
Factorize values with nans replaced by na_sentinel
92+
9093
>>> factorize(np.array([1,2,np.nan], dtype='O'), na_sentinel=20)
9194
array([ 0, 1, 20])
9295
"""
@@ -131,7 +134,10 @@ cdef class Int64Factorizer:
131134
def factorize(self, const int64_t[:] values, sort=False,
132135
na_sentinel=-1, na_value=None):
133136
"""
137+
Examples
138+
--------
134139
Factorize values with nans replaced by na_sentinel
140+
135141
>>> factorize(np.array([1,2,np.nan], dtype='O'), na_sentinel=20)
136142
array([ 0, 1, 20])
137143
"""

pandas/_libs/internals.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ cdef class BlockPlacement:
105105
Py_ssize_t start, stop, end, _
106106
if not self._has_array:
107107
start, stop, step, _ = slice_get_indices_ex(self._as_slice)
108-
self._as_array = np.arange(start, stop, step,
109-
dtype=np.int64)
108+
self._as_array = np.arange(start, stop, step, dtype=np.int64)
110109
self._has_array = True
111110
return self._as_array
112111

@@ -283,8 +282,7 @@ cdef slice_getitem(slice slc, ind):
283282
s_start, s_stop, s_step, s_len = slice_get_indices_ex(slc)
284283

285284
if isinstance(ind, slice):
286-
ind_start, ind_stop, ind_step, ind_len = slice_get_indices_ex(ind,
287-
s_len)
285+
ind_start, ind_stop, ind_step, ind_len = slice_get_indices_ex(ind, s_len)
288286

289287
if ind_step > 0 and ind_len == s_len:
290288
# short-cut for no-op slice

pandas/_libs/interval.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,7 @@ cdef class Interval(IntervalMixin):
481481

482482
@cython.wraparound(False)
483483
@cython.boundscheck(False)
484-
def intervals_to_interval_bounds(ndarray intervals,
485-
bint validate_closed=True):
484+
def intervals_to_interval_bounds(ndarray intervals, bint validate_closed=True):
486485
"""
487486
Parameters
488487
----------

pandas/_libs/join.pyx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -803,18 +803,22 @@ def asof_join_nearest_on_X_by_Y(asof_t[:] left_values,
803803
right_indexer = np.empty(left_size, dtype=np.int64)
804804

805805
# search both forward and backward
806-
bli, bri = asof_join_backward_on_X_by_Y(left_values,
807-
right_values,
808-
left_by_values,
809-
right_by_values,
810-
allow_exact_matches,
811-
tolerance)
812-
fli, fri = asof_join_forward_on_X_by_Y(left_values,
813-
right_values,
814-
left_by_values,
815-
right_by_values,
816-
allow_exact_matches,
817-
tolerance)
806+
bli, bri = asof_join_backward_on_X_by_Y(
807+
left_values,
808+
right_values,
809+
left_by_values,
810+
right_by_values,
811+
allow_exact_matches,
812+
tolerance,
813+
)
814+
fli, fri = asof_join_forward_on_X_by_Y(
815+
left_values,
816+
right_values,
817+
left_by_values,
818+
right_by_values,
819+
allow_exact_matches,
820+
tolerance,
821+
)
818822

819823
for i in range(len(bri)):
820824
# choose timestamp from right with smaller difference

0 commit comments

Comments
 (0)