Skip to content

Commit cc4c0b3

Browse files
CLN: D213: Multi-line docstring summary should start at the second line (#31893)
1 parent 53ece70 commit cc4c0b3

Some content is hidden

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

50 files changed

+258
-129
lines changed

pandas/_config/config.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282

8383

8484
class OptionError(AttributeError, KeyError):
85-
"""Exception for pandas.options, backwards compatible with KeyError
85+
"""
86+
Exception for pandas.options, backwards compatible with KeyError
8687
checks
8788
"""
8889

@@ -545,7 +546,8 @@ def deprecate_option(
545546

546547

547548
def _select_options(pat: str) -> List[str]:
548-
"""returns a list of keys matching `pat`
549+
"""
550+
returns a list of keys matching `pat`
549551
550552
if pat=="all", returns all registered options
551553
"""
@@ -708,7 +710,8 @@ def pp(name: str, ks: Iterable[str]) -> List[str]:
708710

709711
@contextmanager
710712
def config_prefix(prefix):
711-
"""contextmanager for multiple invocations of API with a common prefix
713+
"""
714+
contextmanager for multiple invocations of API with a common prefix
712715
713716
supported API functions: (register / get / set )__option
714717

pandas/_testing.py

+22-11
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,8 @@ def repr_class(x):
743743

744744

745745
def assert_attr_equal(attr, left, right, obj="Attributes"):
746-
"""checks attributes are equal. Both objects must have attribute.
746+
"""
747+
checks attributes are equal. Both objects must have attribute.
747748
748749
Parameters
749750
----------
@@ -820,7 +821,8 @@ def assert_is_sorted(seq):
820821
def assert_categorical_equal(
821822
left, right, check_dtype=True, check_category_order=True, obj="Categorical"
822823
):
823-
"""Test that Categoricals are equivalent.
824+
"""
825+
Test that Categoricals are equivalent.
824826
825827
Parameters
826828
----------
@@ -860,7 +862,8 @@ def assert_categorical_equal(
860862

861863

862864
def assert_interval_array_equal(left, right, exact="equiv", obj="IntervalArray"):
863-
"""Test that two IntervalArrays are equivalent.
865+
"""
866+
Test that two IntervalArrays are equivalent.
864867
865868
Parameters
866869
----------
@@ -1009,7 +1012,8 @@ def _raise(left, right, err_msg):
10091012
def assert_extension_array_equal(
10101013
left, right, check_dtype=True, check_less_precise=False, check_exact=False
10111014
):
1012-
"""Check that left and right ExtensionArrays are equal.
1015+
"""
1016+
Check that left and right ExtensionArrays are equal.
10131017
10141018
Parameters
10151019
----------
@@ -1489,7 +1493,8 @@ def assert_sp_array_equal(
14891493
check_fill_value=True,
14901494
consolidate_block_indices=False,
14911495
):
1492-
"""Check that the left and right SparseArray are equal.
1496+
"""
1497+
Check that the left and right SparseArray are equal.
14931498
14941499
Parameters
14951500
----------
@@ -1724,7 +1729,8 @@ def _make_timeseries(start="2000-01-01", end="2000-12-31", freq="1D", seed=None)
17241729

17251730

17261731
def all_index_generator(k=10):
1727-
"""Generator which can be iterated over to get instances of all the various
1732+
"""
1733+
Generator which can be iterated over to get instances of all the various
17281734
index classes.
17291735
17301736
Parameters
@@ -1763,7 +1769,8 @@ def index_subclass_makers_generator():
17631769

17641770

17651771
def all_timeseries_index_generator(k=10):
1766-
"""Generator which can be iterated over to get instances of all the classes
1772+
"""
1773+
Generator which can be iterated over to get instances of all the classes
17671774
which represent time-series.
17681775
17691776
Parameters
@@ -1854,7 +1861,8 @@ def makePeriodFrame(nper=None):
18541861
def makeCustomIndex(
18551862
nentries, nlevels, prefix="#", names=False, ndupe_l=None, idx_type=None
18561863
):
1857-
"""Create an index/multindex with given dimensions, levels, names, etc'
1864+
"""
1865+
Create an index/multindex with given dimensions, levels, names, etc'
18581866
18591867
nentries - number of entries in index
18601868
nlevels - number of levels (> 1 produces multindex)
@@ -2144,7 +2152,8 @@ def makeMissingDataframe(density=0.9, random_state=None):
21442152

21452153

21462154
def optional_args(decorator):
2147-
"""allows a decorator to take optional positional and keyword arguments.
2155+
"""
2156+
allows a decorator to take optional positional and keyword arguments.
21482157
Assumes that taking a single, callable, positional argument means that
21492158
it is decorating a function, i.e. something like this::
21502159
@@ -2216,7 +2225,8 @@ def _get_default_network_errors():
22162225

22172226

22182227
def can_connect(url, error_classes=None):
2219-
"""Try to connect to the given url. True if succeeds, False if IOError
2228+
"""
2229+
Try to connect to the given url. True if succeeds, False if IOError
22202230
raised
22212231
22222232
Parameters
@@ -2584,7 +2594,8 @@ def use_numexpr(use, min_elements=None):
25842594

25852595

25862596
def test_parallel(num_threads=2, kwargs_list=None):
2587-
"""Decorator to run the same function multiple times in parallel.
2597+
"""
2598+
Decorator to run the same function multiple times in parallel.
25882599
25892600
Parameters
25902601
----------

pandas/compat/chainmap.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66

77
class DeepChainMap(ChainMap[_KT, _VT]):
8-
"""Variant of ChainMap that allows direct updates to inner scopes.
8+
"""
9+
Variant of ChainMap that allows direct updates to inner scopes.
910
1011
Only works when all passed mapping are mutable.
1112
"""

pandas/core/aggregation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[i
9898
def _make_unique_kwarg_list(
9999
seq: Sequence[Tuple[Any, Any]]
100100
) -> Sequence[Tuple[Any, Any]]:
101-
"""Uniquify aggfunc name of the pairs in the order list
101+
"""
102+
Uniquify aggfunc name of the pairs in the order list
102103
103104
Examples:
104105
--------

pandas/core/arrays/base.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""An interface for extending pandas with custom arrays.
1+
"""
2+
An interface for extending pandas with custom arrays.
23
34
.. warning::
45
@@ -213,7 +214,8 @@ def _from_sequence(cls, scalars, dtype=None, copy=False):
213214

214215
@classmethod
215216
def _from_sequence_of_strings(cls, strings, dtype=None, copy=False):
216-
"""Construct a new ExtensionArray from a sequence of strings.
217+
"""
218+
Construct a new ExtensionArray from a sequence of strings.
217219
218220
.. versionadded:: 0.24.0
219221
@@ -961,7 +963,8 @@ def __repr__(self) -> str:
961963
return f"{class_name}{data}\nLength: {len(self)}, dtype: {self.dtype}"
962964

963965
def _formatter(self, boxed: bool = False) -> Callable[[Any], Optional[str]]:
964-
"""Formatting function for scalar values.
966+
"""
967+
Formatting function for scalar values.
965968
966969
This is used in the default '__repr__'. The returned formatting
967970
function receives instances of your scalar type.

pandas/core/arrays/categorical.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,8 @@ def __contains__(self, key) -> bool:
18911891
return contains(self, key, container=self._codes)
18921892

18931893
def _tidy_repr(self, max_vals=10, footer=True) -> str:
1894-
""" a short repr displaying only max_vals and an optional (but default
1894+
"""
1895+
a short repr displaying only max_vals and an optional (but default
18951896
footer)
18961897
"""
18971898
num = max_vals // 2

pandas/core/arrays/datetimelike.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ def _simple_new(cls, values, **kwargs):
134134

135135
@property
136136
def _scalar_type(self) -> Type[DatetimeLikeScalar]:
137-
"""The scalar associated with this datelike
137+
"""
138+
The scalar associated with this datelike
138139
139140
* PeriodArray : Period
140141
* DatetimeArray : Timestamp

pandas/core/arrays/integer.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,8 @@ def astype(self, dtype, copy: bool = True) -> ArrayLike:
477477

478478
@property
479479
def _ndarray_values(self) -> np.ndarray:
480-
"""Internal pandas method for lossy conversion to a NumPy ndarray.
480+
"""
481+
Internal pandas method for lossy conversion to a NumPy ndarray.
481482
482483
This method is not part of the pandas interface.
483484
@@ -492,7 +493,8 @@ def _values_for_factorize(self) -> Tuple[np.ndarray, float]:
492493
return self.to_numpy(na_value=np.nan), np.nan
493494

494495
def _values_for_argsort(self) -> np.ndarray:
495-
"""Return values for sorting.
496+
"""
497+
Return values for sorting.
496498
497499
Returns
498500
-------

pandas/core/arrays/interval.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ def from_tuples(cls, data, closed="right", copy=False, dtype=None):
460460
return cls.from_arrays(left, right, closed, copy=False, dtype=dtype)
461461

462462
def _validate(self):
463-
"""Verify that the IntervalArray is valid.
463+
"""
464+
Verify that the IntervalArray is valid.
464465
465466
Checks that
466467

pandas/core/arrays/sparse/scipy_sparse.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def _check_is_partition(parts, whole):
1717

1818

1919
def _to_ijv(ss, row_levels=(0,), column_levels=(1,), sort_labels=False):
20-
""" For arbitrary (MultiIndexed) sparse Series return
20+
"""
21+
For arbitrary (MultiIndexed) sparse Series return
2122
(v, i, j, ilabels, jlabels) where (v, (i, j)) is suitable for
2223
passing to scipy.sparse.coo constructor.
2324
"""
@@ -44,7 +45,8 @@ def get_indexers(levels):
4445
# labels_to_i[:] = np.arange(labels_to_i.shape[0])
4546

4647
def _get_label_to_i_dict(labels, sort_labels=False):
47-
""" Return dict of unique labels to number.
48+
"""
49+
Return dict of unique labels to number.
4850
Optionally sort by label.
4951
"""
5052
labels = Index(map(tuple, labels)).unique().tolist() # squish

pandas/core/computation/ops.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Operator classes for eval.
1+
"""
2+
Operator classes for eval.
23
"""
34

45
from datetime import datetime
@@ -248,7 +249,8 @@ def is_datetime(self) -> bool:
248249

249250

250251
def _in(x, y):
251-
"""Compute the vectorized membership of ``x in y`` if possible, otherwise
252+
"""
253+
Compute the vectorized membership of ``x in y`` if possible, otherwise
252254
use Python.
253255
"""
254256
try:
@@ -263,7 +265,8 @@ def _in(x, y):
263265

264266

265267
def _not_in(x, y):
266-
"""Compute the vectorized membership of ``x not in y`` if possible,
268+
"""
269+
Compute the vectorized membership of ``x not in y`` if possible,
267270
otherwise use Python.
268271
"""
269272
try:
@@ -445,7 +448,8 @@ def evaluate(self, env, engine: str, parser, term_type, eval_in_python):
445448
return term_type(name, env=env)
446449

447450
def convert_values(self):
448-
"""Convert datetimes to a comparable value in an expression.
451+
"""
452+
Convert datetimes to a comparable value in an expression.
449453
"""
450454

451455
def stringify(value):

pandas/core/computation/parsing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
""":func:`~pandas.eval` source string parsing functions
1+
"""
2+
:func:`~pandas.eval` source string parsing functions
23
"""
34

45
from io import StringIO

pandas/core/computation/pytables.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def is_valid(self) -> bool:
149149

150150
@property
151151
def is_in_table(self) -> bool:
152-
""" return True if this is a valid column name for generation (e.g. an
152+
"""
153+
return True if this is a valid column name for generation (e.g. an
153154
actual column in the table)
154155
"""
155156
return self.queryables.get(self.lhs) is not None
@@ -175,7 +176,8 @@ def generate(self, v) -> str:
175176
return f"({self.lhs} {self.op} {val})"
176177

177178
def convert_value(self, v) -> "TermValue":
178-
""" convert the expression that is in the term to something that is
179+
"""
180+
convert the expression that is in the term to something that is
179181
accepted by pytables
180182
"""
181183

pandas/core/computation/scope.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def ensure_scope(
3131

3232

3333
def _replacer(x) -> str:
34-
"""Replace a number with its hexadecimal representation. Used to tag
34+
"""
35+
Replace a number with its hexadecimal representation. Used to tag
3536
temporary variables with their calling scope's id.
3637
"""
3738
# get the hex repr of the binary char and remove 0x and pad by pad_size

pandas/core/dtypes/cast.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def is_nested_object(obj) -> bool:
105105

106106

107107
def maybe_downcast_to_dtype(result, dtype):
108-
""" try to cast to the specified dtype (e.g. convert back to bool/int
108+
"""
109+
try to cast to the specified dtype (e.g. convert back to bool/int
109110
or could be an astype of float64->float32
110111
"""
111112
do_round = False
@@ -750,7 +751,8 @@ def maybe_upcast(values, fill_value=np.nan, dtype=None, copy: bool = False):
750751

751752

752753
def invalidate_string_dtypes(dtype_set):
753-
"""Change string like dtypes to object for
754+
"""
755+
Change string like dtypes to object for
754756
``DataFrame.select_dtypes()``.
755757
"""
756758
non_string_dtypes = dtype_set - {np.dtype("S").type, np.dtype("<U").type}
@@ -1216,7 +1218,8 @@ def try_timedelta(v):
12161218

12171219

12181220
def maybe_cast_to_datetime(value, dtype, errors: str = "raise"):
1219-
""" try to cast the array/value to a datetimelike dtype, converting float
1221+
"""
1222+
try to cast the array/value to a datetimelike dtype, converting float
12201223
nan to iNaT
12211224
"""
12221225
from pandas.core.tools.timedeltas import to_timedelta

pandas/core/dtypes/concat.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def is_nonempty(x) -> bool:
136136

137137

138138
def concat_categorical(to_concat, axis: int = 0):
139-
"""Concatenate an object/categorical array of arrays, each of which is a
139+
"""
140+
Concatenate an object/categorical array of arrays, each of which is a
140141
single dtype
141142
142143
Parameters

0 commit comments

Comments
 (0)