From f7509757b7b062a4000f8f6eb57fc3bd20292251 Mon Sep 17 00:00:00 2001 From: jamescobonkerr Date: Sun, 3 Mar 2019 18:14:47 +0000 Subject: [PATCH 1/7] Resolve GL03 docstring validation errors --- pandas/_libs/tslibs/timedeltas.pyx | 1 - pandas/core/arrays/datetimes.py | 2 +- pandas/core/arrays/sparse.py | 1 - pandas/core/base.py | 1 - pandas/core/config.py | 2 +- pandas/core/frame.py | 2 -- pandas/core/generic.py | 12 +++--------- pandas/core/groupby/base.py | 2 +- pandas/core/groupby/groupby.py | 6 +++--- pandas/core/indexes/base.py | 1 - pandas/io/feather_format.py | 1 - pandas/plotting/_misc.py | 1 - 12 files changed, 9 insertions(+), 23 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 6e40063fb925a..37aa05659b70f 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1156,7 +1156,6 @@ class Timedelta(_Timedelta): Notes ----- The ``.value`` attribute is always in ns. - """ def __new__(cls, object value=_no_input, unit=None, **kwargs): cdef _Timedelta td_base diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 75cf658423210..89f2b9961a4d7 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -119,7 +119,7 @@ def f(self): return result f.__name__ = name - f.__doc__ = "\n{}\n".format(docstring) + f.__doc__ = docstring return property(f) diff --git a/pandas/core/arrays/sparse.py b/pandas/core/arrays/sparse.py index 9be2c9af169e8..fd7149edc8d7c 100644 --- a/pandas/core/arrays/sparse.py +++ b/pandas/core/arrays/sparse.py @@ -541,7 +541,6 @@ class SparseArray(PandasObject, ExtensionArray, ExtensionOpsMixin): 3. ``data.dtype.fill_value`` if `fill_value` is None and `dtype` is not a ``SparseDtype`` and `data` is a ``SparseArray``. - kind : {'integer', 'block'}, default 'integer' The type of storage for sparse locations. diff --git a/pandas/core/base.py b/pandas/core/base.py index f896596dd5216..c0f3df1b36c03 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -870,7 +870,6 @@ def to_numpy(self, dtype=None, copy=False): .. versionadded:: 0.24.0 - Parameters ---------- dtype : str or numpy.dtype, optional diff --git a/pandas/core/config.py b/pandas/core/config.py index 01664fffb1e27..8cd72691b06e1 100644 --- a/pandas/core/config.py +++ b/pandas/core/config.py @@ -650,8 +650,8 @@ def _build_option_description(k): s += (u(', use `{rkey}` instead.') .format(rkey=d.rkey if d.rkey else '')) s += u(')') + s += '\n' - s += '\n\n' return s diff --git a/pandas/core/frame.py b/pandas/core/frame.py index eadffb779734f..3996728a1cc90 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2184,7 +2184,6 @@ def to_html(self, buf=None, columns=None, col_space=None, header=True, Convert URLs to HTML links. .. versionadded:: 0.24.0 - %(returns)s See Also -------- @@ -6027,7 +6026,6 @@ def unstack(self, level=-1, fill_value=None): columns, considered measured variables (`value_vars`), are "unpivoted" to the row axis, leaving just two non-identifier columns, 'variable' and 'value'. - %(versionadded)s Parameters ---------- diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 0b81576404e2f..5150748a859c5 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -948,7 +948,6 @@ def swaplevel(self, i=-2, j=-1, axis=0): The indexes ``i`` and ``j`` are now optional, and default to the two innermost levels of the index. - """ axis = self._get_axis_number(axis) result = self.copy() @@ -4951,9 +4950,7 @@ def pipe(self, func, *args, **kwargs): _shared_docs['aggregate'] = dedent(""" Aggregate using one or more operations over the specified axis. - %(versionadded)s - Parameters ---------- func : function, str, list or dict @@ -4983,16 +4980,13 @@ def pipe(self, func, *args, **kwargs): * DataFrame : when DataFrame.agg is called with several functions Return scalar, Series or DataFrame. - %(see_also)s - Notes ----- `agg` is an alias for `aggregate`. Use the alias. A passed user-defined-function will be passed a Series for evaluation. - - %(examples)s + %(examples)s\ """) _shared_docs['transform'] = (""" @@ -10307,7 +10301,7 @@ def _doc_parms(cls): Returns ------- -%(name1)s or %(name2)s (if level specified) +%(name1)s or %(name2)s (if level specified)\ %(see_also)s %(examples)s\ """ @@ -10464,7 +10458,7 @@ def _doc_parms(cls): %(name2)s.cumsum : Return cumulative sum over %(name2)s axis. %(name2)s.cumprod : Return cumulative product over %(name2)s axis. -%(examples)s +%(examples)s\ """ _cummin_examples = """\ diff --git a/pandas/core/groupby/base.py b/pandas/core/groupby/base.py index ebba4a0a9395d..f272238ffc4a4 100644 --- a/pandas/core/groupby/base.py +++ b/pandas/core/groupby/base.py @@ -139,7 +139,7 @@ def %(name)s(self) : # ugly, but we need the name string itself in the method. f = getattr(klass, name) doc = f.__doc__ - doc = doc if type(doc) == str else '' + doc = doc.strip() if type(doc) == str else '' if isinstance(f, types.MethodType): wrapper_template = method_wrapper_template decl, args = make_signature(f) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 36dcb692bb079..56ca0f60e76aa 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -44,12 +44,12 @@ class providing the base-class of operations. from pandas.core.series import Series from pandas.core.sorting import get_group_index_sorter -_common_see_also = """ +_common_see_also = """\ See Also -------- Series.%(name)s DataFrame.%(name)s - Panel.%(name)s + Panel.%(name)s\ """ _apply_docs = dict( @@ -221,7 +221,7 @@ class providing the base-class of operations. Examples -------- -%(examples)s +%(examples)s\ """ _transform_template = """ diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index dee181fc1c569..29b9a47a92a48 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -3104,7 +3104,6 @@ def reindex(self, target, method=None, level=None, limit=None, Resulting index. indexer : np.ndarray or None Indices of output values in original index. - """ # GH6552: preserve names when reindexing to non-named target # (i.e. neither Index nor Series). diff --git a/pandas/io/feather_format.py b/pandas/io/feather_format.py index d76e6b75d3762..b2c6dff4338b6 100644 --- a/pandas/io/feather_format.py +++ b/pandas/io/feather_format.py @@ -110,7 +110,6 @@ def read_feather(path, columns=None, use_threads=True): Returns ------- type of object stored in file - """ feather, pyarrow = _try_import() diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index 5171ea68fd497..b8073c89892c5 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -303,7 +303,6 @@ def andrews_curves(frame, class_column, ax=None, samples=200, color=None, Returns ------- class:`matplotlip.axis.Axes` - """ from math import sqrt, pi import matplotlib.pyplot as plt From 19a2a5408e8cbe11b17b9154b99dab93c85dbae9 Mon Sep 17 00:00:00 2001 From: jamescobonkerr Date: Sun, 3 Mar 2019 18:42:21 +0000 Subject: [PATCH 2/7] Update code_checks.sh to validate GL03 --- ci/code_checks.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index c4840f1e836c4..51df779341ed5 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -241,8 +241,8 @@ fi ### DOCSTRINGS ### if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then - MSG='Validate docstrings (GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT04, RT05, SA05)' ; echo $MSG - $BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT04,RT05,SA05 + MSG='Validate docstrings (GL03, GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT04, RT05, SA05)' ; echo $MSG + $BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL03,GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT04,RT05,SA05 RET=$(($RET + $?)) ; echo $MSG "DONE" fi From 4a29b06e748c64d2d2bd6cc17d0e3370e49b9a79 Mon Sep 17 00:00:00 2001 From: jamescobonkerr Date: Sun, 3 Mar 2019 18:51:26 +0000 Subject: [PATCH 3/7] Remove newline concat in _build_option_description function --- pandas/core/config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/config.py b/pandas/core/config.py index 8cd72691b06e1..b6264a5257dcb 100644 --- a/pandas/core/config.py +++ b/pandas/core/config.py @@ -650,7 +650,6 @@ def _build_option_description(k): s += (u(', use `{rkey}` instead.') .format(rkey=d.rkey if d.rkey else '')) s += u(')') - s += '\n' return s From b497384424315ce79dd87621e8b823def7c61d55 Mon Sep 17 00:00:00 2001 From: jamescobonkerr Date: Sun, 3 Mar 2019 20:20:00 +0000 Subject: [PATCH 4/7] Resolve PR04 errors --- pandas/core/groupby/groupby.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 56ca0f60e76aa..e173849b3828d 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -44,12 +44,12 @@ class providing the base-class of operations. from pandas.core.series import Series from pandas.core.sorting import get_group_index_sorter -_common_see_also = """\ +_common_see_also = """ See Also -------- Series.%(name)s DataFrame.%(name)s - Panel.%(name)s\ + Panel.%(name)s """ _apply_docs = dict( @@ -1106,9 +1106,7 @@ def mean(self, *args, **kwargs): Returns ------- pandas.Series or pandas.DataFrame - %(see_also)s - Examples -------- >>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2], @@ -1564,9 +1562,7 @@ def nth(self, n, dropna=None): dropna : None or str, optional apply the specified dropna operation before counting which row is the nth row. Needs to be None, 'any' or 'all' - %(see_also)s - Examples -------- @@ -2139,9 +2135,7 @@ def head(self, n=5): Essentially equivalent to ``.apply(lambda x: x.head(n))``, except ignores as_index flag. - %(see_also)s - Examples -------- @@ -2167,9 +2161,7 @@ def tail(self, n=5): Essentially equivalent to ``.apply(lambda x: x.tail(n))``, except ignores as_index flag. - %(see_also)s - Examples -------- From 754336e086a6ebd9d730d113b24f7467deffeebc Mon Sep 17 00:00:00 2001 From: jamescobonkerr Date: Sat, 9 Mar 2019 16:15:42 +0000 Subject: [PATCH 5/7] Resolve remaining SS04 errors --- pandas/core/groupby/base.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/core/groupby/base.py b/pandas/core/groupby/base.py index f272238ffc4a4..903c898b68873 100644 --- a/pandas/core/groupby/base.py +++ b/pandas/core/groupby/base.py @@ -126,9 +126,7 @@ class where members are defined. property_wrapper_template = \ """@property def %(name)s(self) : - \""" - %(doc)s - \""" + \"""%(doc)s\""" return self.__getattr__('%(name)s')""" for name in whitelist: @@ -139,7 +137,7 @@ def %(name)s(self) : # ugly, but we need the name string itself in the method. f = getattr(klass, name) doc = f.__doc__ - doc = doc.strip() if type(doc) == str else '' + doc = doc if type(doc) == str else '' if isinstance(f, types.MethodType): wrapper_template = method_wrapper_template decl, args = make_signature(f) From c7ad2e79aa9ea95670b1a93e860f80f65c6af2dc Mon Sep 17 00:00:00 2001 From: jamescobonkerr Date: Sat, 9 Mar 2019 22:43:03 +0000 Subject: [PATCH 6/7] Remove newline from end of _cnum_doc string --- pandas/core/generic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 5150748a859c5..b8884e68d0a36 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10458,8 +10458,7 @@ def _doc_parms(cls): %(name2)s.cumsum : Return cumulative sum over %(name2)s axis. %(name2)s.cumprod : Return cumulative product over %(name2)s axis. -%(examples)s\ -""" +%(examples)s""" _cummin_examples = """\ Examples From 6e79af01cb6c19eccd27986e2c5e4a7fa6b55a98 Mon Sep 17 00:00:00 2001 From: jamescobonkerr Date: Sun, 10 Mar 2019 00:07:40 +0000 Subject: [PATCH 7/7] Move terminating quotes to same line to avoid line breaks --- pandas/core/generic.py | 3 +-- pandas/core/groupby/groupby.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index b8884e68d0a36..d2b87d79c7d52 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4986,8 +4986,7 @@ def pipe(self, func, *args, **kwargs): `agg` is an alias for `aggregate`. Use the alias. A passed user-defined-function will be passed a Series for evaluation. - %(examples)s\ - """) + %(examples)s""") _shared_docs['transform'] = (""" Call ``func`` on self producing a %(klass)s with transformed values diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index e173849b3828d..3d0a6023ac29f 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -221,8 +221,7 @@ class providing the base-class of operations. Examples -------- -%(examples)s\ -""" +%(examples)s""" _transform_template = """ Call function producing a like-indexed %(klass)s on each group and