Skip to content

Commit db01777

Browse files
ShaharNavehproost
authored andcommitted
Remove blank lines under docstring, Put underscores (pandas-dev#30156)
1 parent 02770f4 commit db01777

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

pandas/_libs/groupby.pyx

-4
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ def group_cumprod_float64(float64_t[:, :] out,
175175
-----
176176
This method modifies the `out` parameter, rather than returning an object.
177177
"""
178-
179178
cdef:
180179
Py_ssize_t i, j, N, K, size
181180
float64_t val
@@ -233,7 +232,6 @@ def group_cumsum(numeric[:, :] out,
233232
-----
234233
This method modifies the `out` parameter, rather than returning an object.
235234
"""
236-
237235
cdef:
238236
Py_ssize_t i, j, N, K, size
239237
numeric val
@@ -1404,7 +1402,6 @@ def group_cummin(groupby_t[:, :] out,
14041402
-----
14051403
This method modifies the `out` parameter, rather than returning an object.
14061404
"""
1407-
14081405
cdef:
14091406
Py_ssize_t i, j, N, K, size
14101407
groupby_t val, mval
@@ -1465,7 +1462,6 @@ def group_cummax(groupby_t[:, :] out,
14651462
-----
14661463
This method modifies the `out` parameter, rather than returning an object.
14671464
"""
1468-
14691465
cdef:
14701466
Py_ssize_t i, j, N, K, size
14711467
groupby_t val, mval

pandas/_libs/hashing.pyx

+10-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ def hash_object_array(object[:] arr, object key, object encoding='utf8'):
2525
2626
Returns
2727
-------
28-
1-d uint64 ndarray of hashes
28+
1-d uint64 ndarray of hashes.
29+
30+
Raises
31+
------
32+
TypeError
33+
If the array contains mixed types.
2934
3035
Notes
3136
-----
32-
allowed values must be strings, or nulls
33-
mixed array types will raise TypeError
34-
37+
Allowed values must be strings, or nulls
38+
mixed array types will raise TypeError.
3539
"""
3640
cdef:
3741
Py_ssize_t i, l, n
@@ -47,7 +51,7 @@ def hash_object_array(object[:] arr, object key, object encoding='utf8'):
4751
k = <bytes>key.encode(encoding)
4852
kb = <uint8_t *>k
4953
if len(k) != 16:
50-
raise ValueError(f"key should be a 16-byte string encoded, "
54+
raise ValueError("key should be a 16-byte string encoded, "
5155
f"got {k} (len {len(k)})")
5256

5357
n = len(arr)
@@ -68,8 +72,7 @@ def hash_object_array(object[:] arr, object key, object encoding='utf8'):
6872

6973
else:
7074
raise TypeError(f"{val} of type {type(val)} is not a valid type "
71-
f"for hashing, must be string or null"
72-
)
75+
"for hashing, must be string or null")
7376

7477
l = len(data)
7578
lens[i] = l

pandas/_libs/hashtable.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ cdef class Int64Factorizer:
142142
@cython.boundscheck(False)
143143
def unique_label_indices(const int64_t[:] labels):
144144
"""
145-
indices of the first occurrences of the unique labels
145+
Indices of the first occurrences of the unique labels
146146
*excluding* -1. equivalent to:
147147
np.unique(labels, return_index=True)[1]
148148
"""

pandas/_libs/index.pyx

+23-20
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cpdef get_value_at(ndarray arr, object loc, object tz=None):
5252

5353

5454
# Don't populate hash tables in monotonic indexes larger than this
55-
_SIZE_CUTOFF = 1000000
55+
_SIZE_CUTOFF = 1_000_000
5656

5757

5858
cdef class IndexEngine:
@@ -79,6 +79,8 @@ cdef class IndexEngine:
7979

8080
cpdef get_value(self, ndarray arr, object key, object tz=None):
8181
"""
82+
Parameters
83+
----------
8284
arr : 1-dimensional ndarray
8385
"""
8486
cdef:
@@ -93,6 +95,8 @@ cdef class IndexEngine:
9395

9496
cpdef set_value(self, ndarray arr, object key, object value):
9597
"""
98+
Parameters
99+
----------
96100
arr : 1-dimensional ndarray
97101
"""
98102
cdef:
@@ -283,11 +287,12 @@ cdef class IndexEngine:
283287
return self.mapping.lookup(values)
284288

285289
def get_indexer_non_unique(self, targets):
286-
""" return an indexer suitable for takng from a non unique index
287-
return the labels in the same order ast the target
288-
and a missing indexer into the targets (which correspond
289-
to the -1 indices in the results """
290-
290+
"""
291+
Return an indexer suitable for takng from a non unique index
292+
return the labels in the same order ast the target
293+
and a missing indexer into the targets (which correspond
294+
to the -1 indices in the results
295+
"""
291296
cdef:
292297
ndarray values, x
293298
ndarray[int64_t] result, missing
@@ -302,8 +307,8 @@ cdef class IndexEngine:
302307
stargets = set(targets)
303308
n = len(values)
304309
n_t = len(targets)
305-
if n > 10000:
306-
n_alloc = 10000
310+
if n > 10_000:
311+
n_alloc = 10_000
307312
else:
308313
n_alloc = n
309314

@@ -345,7 +350,7 @@ cdef class IndexEngine:
345350

346351
# realloc if needed
347352
if count >= n_alloc:
348-
n_alloc += 10000
353+
n_alloc += 10_000
349354
result = np.resize(result, n_alloc)
350355

351356
result[count] = j
@@ -355,7 +360,7 @@ cdef class IndexEngine:
355360
else:
356361

357362
if count >= n_alloc:
358-
n_alloc += 10000
363+
n_alloc += 10_000
359364
result = np.resize(result, n_alloc)
360365
result[count] = -1
361366
count += 1
@@ -393,7 +398,7 @@ cdef Py_ssize_t _bin_search(ndarray values, object val) except -1:
393398

394399
cdef class ObjectEngine(IndexEngine):
395400
"""
396-
Index Engine for use with object-dtype Index, namely the base class Index
401+
Index Engine for use with object-dtype Index, namely the base class Index.
397402
"""
398403
cdef _make_hash_table(self, Py_ssize_t n):
399404
return _hash.PyObjectHashTable(n)
@@ -560,7 +565,7 @@ cpdef convert_scalar(ndarray arr, object value):
560565
pass
561566
elif value is None or value != value:
562567
return np.datetime64("NaT", "ns")
563-
raise ValueError(f"cannot set a Timestamp with a non-timestamp "
568+
raise ValueError("cannot set a Timestamp with a non-timestamp "
564569
f"{type(value).__name__}")
565570

566571
elif arr.descr.type_num == NPY_TIMEDELTA:
@@ -577,17 +582,17 @@ cpdef convert_scalar(ndarray arr, object value):
577582
pass
578583
elif value is None or value != value:
579584
return np.timedelta64("NaT", "ns")
580-
raise ValueError(f"cannot set a Timedelta with a non-timedelta "
585+
raise ValueError("cannot set a Timedelta with a non-timedelta "
581586
f"{type(value).__name__}")
582587

583588
if (issubclass(arr.dtype.type, (np.integer, np.floating, np.complex)) and
584589
not issubclass(arr.dtype.type, np.bool_)):
585590
if util.is_bool_object(value):
586-
raise ValueError('Cannot assign bool to float/integer series')
591+
raise ValueError("Cannot assign bool to float/integer series")
587592

588593
if issubclass(arr.dtype.type, (np.integer, np.bool_)):
589594
if util.is_float_object(value) and value != value:
590-
raise ValueError('Cannot assign nan to integer series')
595+
raise ValueError("Cannot assign nan to integer series")
591596

592597
return value
593598

@@ -625,13 +630,12 @@ cdef class BaseMultiIndexCodesEngine:
625630
Parameters
626631
----------
627632
levels : list-like of numpy arrays
628-
Levels of the MultiIndex
633+
Levels of the MultiIndex.
629634
labels : list-like of numpy arrays of integer dtype
630-
Labels of the MultiIndex
635+
Labels of the MultiIndex.
631636
offsets : numpy array of uint64 dtype
632-
Pre-calculated offsets, one for each level of the index
637+
Pre-calculated offsets, one for each level of the index.
633638
"""
634-
635639
self.levels = levels
636640
self.offsets = offsets
637641

@@ -664,7 +668,6 @@ cdef class BaseMultiIndexCodesEngine:
664668
int_keys : 1-dimensional array of dtype uint64 or object
665669
Integers representing one combination each
666670
"""
667-
668671
level_codes = [lev.get_indexer(codes) + 1 for lev, codes
669672
in zip(self.levels, zip(*target))]
670673
return self._codes_to_ints(np.array(level_codes, dtype='uint64').T)

pandas/_libs/indexing.pyx

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ cdef class _NDFrameIndexerBase:
1818
if ndim is None:
1919
ndim = self._ndim = self.obj.ndim
2020
if ndim > 2:
21-
msg = ("NDFrameIndexer does not support NDFrame objects with"
22-
" ndim > 2")
23-
raise ValueError(msg)
21+
raise ValueError("NDFrameIndexer does not support "
22+
"NDFrame objects with ndim > 2")
2423
return ndim

0 commit comments

Comments
 (0)