Skip to content

DOC: Remove flake8 errors for basics.rst and contributing_docstring.rst #24598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/source/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -807,15 +807,15 @@ Compare the following
.. code-block:: python

# f, g, and h are functions taking and returning ``DataFrames``
>>> f(g(h(df), arg1=1), arg2=2, arg3=3)
>>> f(g(h(df), arg1=1), arg2=2, arg3=3) # noqa F821
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this is really ugly, @datapythonista ?


with the equivalent

.. code-block:: python

>>> (df.pipe(h)
... .pipe(g, arg1=1)
... .pipe(f, arg2=2, arg3=3))
>>> (df.pipe(h) # noqa F821
... .pipe(g, arg1=1) # noqa F821
... .pipe(f, arg2=2, arg3=3)) # noqa F821

Pandas encourages the second style, which is known as method chaining.
``pipe`` makes it easy to use your own or another library's functions
Expand Down
44 changes: 23 additions & 21 deletions doc/source/contributing_docstring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ Next example gives an idea on how a docstring looks like:

Examples
--------
>>> add(2, 2)
>>> add(2, 2) # noqa F821
4
>>> add(25, 0)
>>> add(25, 0) # noqa F821
25
>>> add(10, -10)
>>> add(10, -10) # noqa F821
0
"""
return num1 + num2
Expand Down Expand Up @@ -187,7 +187,7 @@ infinitive verb.

.. code-block:: python

def astype(dtype):
def astype(dtype): # noqa F811
"""
Casts Series type.

Expand All @@ -197,7 +197,7 @@ infinitive verb.

.. code-block:: python

def astype(dtype):
def astype(dtype): # noqa F811
"""
Method to cast Series type.

Expand All @@ -207,7 +207,7 @@ infinitive verb.

.. code-block:: python

def astype(dtype):
def astype(dtype): # noqa F811
"""
Cast Series type

Expand All @@ -217,7 +217,7 @@ infinitive verb.

.. code-block:: python

def astype(dtype):
def astype(dtype): # noqa F811
"""
Cast Series type from its current type to the new type defined in
the parameter dtype.
Expand Down Expand Up @@ -322,7 +322,7 @@ would be used, then we will specify "str, int or None, default None".

.. code-block:: python

class Series:
class Series: # noqa F811
def plot(self, kind, **kwargs):
"""
Generate a plot.
Expand Down Expand Up @@ -457,12 +457,14 @@ For example, with a single value:
float
Random number generated.
"""
return random.random()
return np.random.random()

With more than one value:

.. code-block:: python

import string

def random_letters():
"""
Generate and return a sequence of random letters.
Expand All @@ -477,8 +479,8 @@ With more than one value:
letters : str
String of random letters.
"""
length = random.randint(1, 10)
letters = ''.join(random.choice(string.ascii_lowercase)
length = np.random.randint(1, 10)
letters = ''.join(np.random.choice(string.ascii_lowercase)
for i in range(length))
return length, letters

Expand All @@ -499,7 +501,7 @@ If the method yields its value:
Random number generated.
"""
while True:
yield random.random()
yield np.random.random()

.. _docstring.see_also:

Expand Down Expand Up @@ -558,7 +560,7 @@ For example:

.. code-block:: python

class Series:
class Series: # noqa F811
def head(self):
"""
Return the first 5 elements of the Series.
Expand Down Expand Up @@ -776,7 +778,7 @@ positional arguments ``head(3)``.

Examples
--------
>>> s = pd.Series('Antelope', 'Lion', 'Zebra', numpy.nan)
>>> s = pd.Series('Antelope', 'Lion', 'Zebra', np.nan)
>>> s.contains(pattern='a')
0 False
1 False
Expand Down Expand Up @@ -834,7 +836,7 @@ positional arguments ``head(3)``.
--------
>>> import numpy as np
>>> import pandas as pd
>>> df = pd.DataFrame(numpy.random.randn(3, 3),
>>> df = pd.DataFrame(np.random.randn(3, 3),
... columns=('a', 'b', 'c'))
>>> df.method(1)
21
Expand Down Expand Up @@ -909,7 +911,7 @@ plot will be generated automatically when building the documentation.

.. code-block:: python

class Series:
class Series: # noqa F811
def plot(self):
"""
Generate a plot with the `Series` data.
Expand Down Expand Up @@ -953,15 +955,15 @@ substitute the children's class names in this docstring.


class ChildA(Parent):
@Substitution(klass="ChildA")
@Appender(Parent.my_function.__doc__)
@Substitution(klass="ChildA") # noqa F821
@Appender(Parent.my_function.__doc__) # noqa F821
def my_function(self):
...


class ChildB(Parent):
@Substitution(klass="ChildB")
@Appender(Parent.my_function.__doc__)
@Substitution(klass="ChildB") # noqa F821
@Appender(Parent.my_function.__doc__) # noqa F821
def my_function(self):
...

Expand Down Expand Up @@ -990,7 +992,7 @@ You can substitute and append in one shot with something like

.. code-block:: python

@Appender(template % _shared_doc_kwargs)
@Appender(template % _shared_doc_kwargs) # noqa F821
def my_function(self):
...

Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ exclude =
doc/source/whatsnew/v0.15.0.rst
doc/source/whatsnew/v0.15.1.rst
doc/source/whatsnew/v0.15.2.rst
doc/source/basics.rst
doc/source/contributing_docstring.rst
doc/source/enhancingperf.rst


Expand Down