Skip to content

Commit 97054ac

Browse files
D202 No blank lines allowed after function docstring (#31895)
1 parent bc6ab05 commit 97054ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1
-361
lines changed

pandas/_config/config.py

-10
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ def _select_options(pat: str) -> List[str]:
550550
551551
if pat=="all", returns all registered options
552552
"""
553-
554553
# short-circuit for exact key
555554
if pat in _registered_options:
556555
return [pat]
@@ -573,7 +572,6 @@ def _get_root(key: str) -> Tuple[Dict[str, Any], str]:
573572

574573
def _is_deprecated(key: str) -> bool:
575574
""" Returns True if the given option has been deprecated """
576-
577575
key = key.lower()
578576
return key in _deprecated_options
579577

@@ -586,7 +584,6 @@ def _get_deprecated_option(key: str):
586584
-------
587585
DeprecatedOption (namedtuple) if key is deprecated, None otherwise
588586
"""
589-
590587
try:
591588
d = _deprecated_options[key]
592589
except KeyError:
@@ -611,7 +608,6 @@ def _translate_key(key: str) -> str:
611608
if key id deprecated and a replacement key defined, will return the
612609
replacement key, otherwise returns `key` as - is
613610
"""
614-
615611
d = _get_deprecated_option(key)
616612
if d:
617613
return d.rkey or key
@@ -627,7 +623,6 @@ def _warn_if_deprecated(key: str) -> bool:
627623
-------
628624
bool - True if `key` is deprecated, False otherwise.
629625
"""
630-
631626
d = _get_deprecated_option(key)
632627
if d:
633628
if d.msg:
@@ -649,7 +644,6 @@ def _warn_if_deprecated(key: str) -> bool:
649644

650645
def _build_option_description(k: str) -> str:
651646
""" Builds a formatted description of a registered option and prints it """
652-
653647
o = _get_registered_option(k)
654648
d = _get_deprecated_option(k)
655649

@@ -674,7 +668,6 @@ def _build_option_description(k: str) -> str:
674668

675669
def pp_options_list(keys: Iterable[str], width=80, _print: bool = False):
676670
""" Builds a concise listing of available options, grouped by prefix """
677-
678671
from textwrap import wrap
679672
from itertools import groupby
680673

@@ -738,7 +731,6 @@ def config_prefix(prefix):
738731
will register options "display.font.color", "display.font.size", set the
739732
value of "display.font.size"... and so on.
740733
"""
741-
742734
# Note: reset_option relies on set_option, and on key directly
743735
# it does not fit in to this monkey-patching scheme
744736

@@ -801,7 +793,6 @@ def is_instance_factory(_type) -> Callable[[Any], None]:
801793
ValueError if x is not an instance of `_type`
802794
803795
"""
804-
805796
if isinstance(_type, (tuple, list)):
806797
_type = tuple(_type)
807798
type_repr = "|".join(map(str, _type))
@@ -848,7 +839,6 @@ def is_nonnegative_int(value: Optional[int]) -> None:
848839
ValueError
849840
When the value is not None or is a negative integer
850841
"""
851-
852842
if value is None:
853843
return
854844

pandas/_config/localization.py

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def can_set_locale(lc: str, lc_var: int = locale.LC_ALL) -> bool:
6161
bool
6262
Whether the passed locale can be set
6363
"""
64-
6564
try:
6665
with set_locale(lc, lc_var=lc_var):
6766
pass

pandas/_testing.py

-6
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,6 @@ def assert_sp_array_equal(
15081508
create a new BlockIndex for that array, with consolidated
15091509
block indices.
15101510
"""
1511-
15121511
_check_isinstance(left, right, pd.arrays.SparseArray)
15131512

15141513
assert_numpy_array_equal(left.sp_values, right.sp_values, check_dtype=check_dtype)
@@ -1876,7 +1875,6 @@ def makeCustomIndex(
18761875
18771876
if unspecified, string labels will be generated.
18781877
"""
1879-
18801878
if ndupe_l is None:
18811879
ndupe_l = [1] * nlevels
18821880
assert is_sequence(ndupe_l) and len(ndupe_l) <= nlevels
@@ -2025,7 +2023,6 @@ def makeCustomDataframe(
20252023
20262024
>> a=mkdf(5,3,r_idx_nlevels=2,c_idx_nlevels=4)
20272025
"""
2028-
20292026
assert c_idx_nlevels > 0
20302027
assert r_idx_nlevels > 0
20312028
assert r_idx_type is None or (
@@ -2229,7 +2226,6 @@ def can_connect(url, error_classes=None):
22292226
Return True if no IOError (unable to connect) or URLError (bad url) was
22302227
raised
22312228
"""
2232-
22332229
if error_classes is None:
22342230
error_classes = _get_default_network_errors()
22352231

@@ -2603,7 +2599,6 @@ def test_parallel(num_threads=2, kwargs_list=None):
26032599
https://github.com/scikit-image/scikit-image/pull/1519
26042600
26052601
"""
2606-
26072602
assert num_threads > 0
26082603
has_kwargs_list = kwargs_list is not None
26092604
if has_kwargs_list:
@@ -2685,7 +2680,6 @@ def set_timezone(tz: str):
26852680
...
26862681
'EDT'
26872682
"""
2688-
26892683
import os
26902684
import time
26912685

pandas/compat/numpy/function.py

-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def validate_argmin_with_skipna(skipna, args, kwargs):
9999
'skipna' parameter is either an instance of ndarray or
100100
is None, since 'skipna' itself should be a boolean
101101
"""
102-
103102
skipna, args = process_skipna(skipna, args)
104103
validate_argmin(args, kwargs)
105104
return skipna
@@ -113,7 +112,6 @@ def validate_argmax_with_skipna(skipna, args, kwargs):
113112
'skipna' parameter is either an instance of ndarray or
114113
is None, since 'skipna' itself should be a boolean
115114
"""
116-
117115
skipna, args = process_skipna(skipna, args)
118116
validate_argmax(args, kwargs)
119117
return skipna
@@ -151,7 +149,6 @@ def validate_argsort_with_ascending(ascending, args, kwargs):
151149
either integer type or is None, since 'ascending' itself should
152150
be a boolean
153151
"""
154-
155152
if is_integer(ascending) or ascending is None:
156153
args = (ascending,) + args
157154
ascending = True
@@ -173,7 +170,6 @@ def validate_clip_with_axis(axis, args, kwargs):
173170
so check if the 'axis' parameter is an instance of ndarray, since
174171
'axis' itself should either be an integer or None
175172
"""
176-
177173
if isinstance(axis, ndarray):
178174
args = (axis,) + args
179175
axis = None
@@ -298,7 +294,6 @@ def validate_take_with_convert(convert, args, kwargs):
298294
ndarray or 'None', so check if the 'convert' parameter is either
299295
an instance of ndarray or is None
300296
"""
301-
302297
if isinstance(convert, ndarray) or convert is None:
303298
args = (convert,) + args
304299
convert = True

pandas/compat/pickle_compat.py

-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ def load(fh, encoding: Optional[str] = None, is_verbose: bool = False):
229229
encoding : an optional encoding
230230
is_verbose : show exception output
231231
"""
232-
233232
try:
234233
fh.seek(0)
235234
if encoding is not None:

pandas/conftest.py

-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def ip():
118118
119119
Will raise a skip if IPython is not installed.
120120
"""
121-
122121
pytest.importorskip("IPython", minversion="6.0.0")
123122
from IPython.core.interactiveshell import InteractiveShell
124123

@@ -679,7 +678,6 @@ def any_nullable_int_dtype(request):
679678
* 'UInt64'
680679
* 'Int64'
681680
"""
682-
683681
return request.param
684682

685683

pandas/core/algorithms.py

-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def _ensure_data(values, dtype=None):
8585
values : ndarray
8686
pandas_dtype : str or dtype
8787
"""
88-
8988
# we check some simple dtypes first
9089
if is_object_dtype(dtype):
9190
return ensure_object(np.asarray(values)), "object"
@@ -182,7 +181,6 @@ def _reconstruct_data(values, dtype, original):
182181
-------
183182
Index for extension types, otherwise ndarray casted to dtype
184183
"""
185-
186184
if is_extension_array_dtype(dtype):
187185
values = dtype.construct_array_type()._from_sequence(values)
188186
elif is_bool_dtype(dtype):
@@ -368,7 +366,6 @@ def unique(values):
368366
>>> pd.unique([('a', 'b'), ('b', 'a'), ('a', 'c'), ('b', 'a')])
369367
array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
370368
"""
371-
372369
values = _ensure_arraylike(values)
373370

374371
if is_extension_array_dtype(values):
@@ -791,7 +788,6 @@ def duplicated(values, keep="first") -> np.ndarray:
791788
-------
792789
duplicated : ndarray
793790
"""
794-
795791
values, _ = _ensure_data(values)
796792
ndtype = values.dtype.name
797793
f = getattr(htable, f"duplicated_{ndtype}")

pandas/core/apply.py

-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def frame_apply(
3535
kwds=None,
3636
):
3737
""" construct and return a row or column based frame apply object """
38-
3938
axis = obj._get_axis_number(axis)
4039
klass: Type[FrameApply]
4140
if axis == 0:
@@ -144,7 +143,6 @@ def agg_axis(self) -> "Index":
144143

145144
def get_result(self):
146145
""" compute the results """
147-
148146
# dispatch to agg
149147
if is_list_like(self.f) or is_dict_like(self.f):
150148
return self.obj.aggregate(self.f, axis=self.axis, *self.args, **self.kwds)
@@ -193,7 +191,6 @@ def apply_empty_result(self):
193191
we will try to apply the function to an empty
194192
series in order to see if this is a reduction function
195193
"""
196-
197194
# we are not asked to reduce or infer reduction
198195
# so just return a copy of the existing object
199196
if self.result_type not in ["reduce", None]:
@@ -396,7 +393,6 @@ def wrap_results_for_axis(
396393
self, results: ResType, res_index: "Index"
397394
) -> "DataFrame":
398395
""" return the results for the rows """
399-
400396
result = self.obj._constructor(data=results)
401397

402398
if not isinstance(results[0], ABCSeries):
@@ -457,7 +453,6 @@ def wrap_results_for_axis(
457453

458454
def infer_to_same_shape(self, results: ResType, res_index: "Index") -> "DataFrame":
459455
""" infer the results to the same shape as the input object """
460-
461456
result = self.obj._constructor(data=results)
462457
result = result.T
463458

pandas/core/arrays/categorical.py

-6
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,6 @@ def _set_categories(self, categories, fastpath=False):
701701
[a, c]
702702
Categories (2, object): [a, c]
703703
"""
704-
705704
if fastpath:
706705
new_dtype = CategoricalDtype._from_fastpath(categories, self.ordered)
707706
else:
@@ -1227,7 +1226,6 @@ def shape(self):
12271226
-------
12281227
shape : tuple
12291228
"""
1230-
12311229
return tuple([len(self._codes)])
12321230

12331231
def shift(self, periods, fill_value=None):
@@ -1384,7 +1382,6 @@ def isna(self):
13841382
Categorical.notna : Boolean inverse of Categorical.isna.
13851383
13861384
"""
1387-
13881385
ret = self._codes == -1
13891386
return ret
13901387

@@ -1934,7 +1931,6 @@ def _repr_categories_info(self) -> str:
19341931
"""
19351932
Returns a string representation of the footer.
19361933
"""
1937-
19381934
category_strs = self._repr_categories()
19391935
dtype = str(self.categories.dtype)
19401936
levheader = f"Categories ({len(self.categories)}, {dtype}): "
@@ -2260,7 +2256,6 @@ def unique(self):
22602256
Series.unique
22612257
22622258
"""
2263-
22642259
# unlike np.unique, unique1d does not sort
22652260
unique_codes = unique1d(self.codes)
22662261
cat = self.copy()
@@ -2320,7 +2315,6 @@ def is_dtype_equal(self, other):
23202315
-------
23212316
bool
23222317
"""
2323-
23242318
try:
23252319
return hash(self.dtype) == hash(other.dtype)
23262320
except (AttributeError, TypeError):

pandas/core/arrays/datetimelike.py

-2
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ def __getitem__(self, key):
500500
This getitem defers to the underlying array, which by-definition can
501501
only handle list-likes, slices, and integer scalars
502502
"""
503-
504503
is_int = lib.is_integer(key)
505504
if lib.is_scalar(key) and not is_int:
506505
raise IndexError(
@@ -892,7 +891,6 @@ def _maybe_mask_results(self, result, fill_value=iNaT, convert=None):
892891
893892
This is an internal routine.
894893
"""
895-
896894
if self._hasnans:
897895
if convert:
898896
result = result.astype(convert)

pandas/core/arrays/integer.py

-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ def safe_cast(values, dtype, copy: bool):
152152
ints.
153153
154154
"""
155-
156155
try:
157156
return values.astype(dtype, casting="safe", copy=copy)
158157
except TypeError:
@@ -600,7 +599,6 @@ def _maybe_mask_result(self, result, mask, other, op_name: str):
600599
other : scalar or array-like
601600
op_name : str
602601
"""
603-
604602
# if we have a float operand we are by-definition
605603
# a float result
606604
# or our op is a divide

pandas/core/arrays/period.py

-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ def _addsub_int_array(
624624
-------
625625
result : PeriodArray
626626
"""
627-
628627
assert op in [operator.add, operator.sub]
629628
if op is operator.sub:
630629
other = -other

pandas/core/arrays/sparse/array.py

-1
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,6 @@ def make_sparse(arr, kind="block", fill_value=None, dtype=None, copy=False):
15031503
-------
15041504
(sparse_values, index, fill_value) : (ndarray, SparseIndex, Scalar)
15051505
"""
1506-
15071506
arr = com.values_from_object(arr)
15081507

15091508
if arr.ndim > 1:

pandas/core/arrays/sparse/scipy_sparse.py

-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def _to_ijv(ss, row_levels=(0,), column_levels=(1,), sort_labels=False):
3131

3232
def get_indexers(levels):
3333
""" Return sparse coords and dense labels for subset levels """
34-
3534
# TODO: how to do this better? cleanly slice nonnull_labels given the
3635
# coord
3736
values_ilabels = [tuple(x[i] for i in levels) for x in nonnull_labels.index]
@@ -90,7 +89,6 @@ def _sparse_series_to_coo(ss, row_levels=(0,), column_levels=(1,), sort_labels=F
9089
levels row_levels, column_levels as the row and column
9190
labels respectively. Returns the sparse_matrix, row and column labels.
9291
"""
93-
9492
import scipy.sparse
9593

9694
if ss.index.nlevels < 2:

pandas/core/common.py

-2
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ def apply_if_callable(maybe_callable, obj, **kwargs):
337337
obj : NDFrame
338338
**kwargs
339339
"""
340-
341340
if callable(maybe_callable):
342341
return maybe_callable(obj, **kwargs)
343342

@@ -412,7 +411,6 @@ def random_state(state=None):
412411
-------
413412
np.random.RandomState
414413
"""
415-
416414
if is_integer(state):
417415
return np.random.RandomState(state)
418416
elif isinstance(state, np.random.RandomState):

0 commit comments

Comments
 (0)