Skip to content

Commit f8f8950

Browse files
DOC: Remove flake8 errors for basics.rst and contributing_docstring.rst
1 parent 62506ca commit f8f8950

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

doc/source/basics.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,15 +807,15 @@ Compare the following
807807
.. code-block:: python
808808
809809
# f, g, and h are functions taking and returning ``DataFrames``
810-
>>> f(g(h(df), arg1=1), arg2=2, arg3=3)
810+
>>> f(g(h(df), arg1=1), arg2=2, arg3=3) # noqa F821
811811
812812
with the equivalent
813813

814814
.. code-block:: python
815815
816-
>>> (df.pipe(h)
817-
... .pipe(g, arg1=1)
818-
... .pipe(f, arg2=2, arg3=3))
816+
>>> (df.pipe(h) # noqa F821
817+
... .pipe(g, arg1=1) # noqa F821
818+
... .pipe(f, arg2=2, arg3=3)) # noqa F821
819819
820820
Pandas encourages the second style, which is known as method chaining.
821821
``pipe`` makes it easy to use your own or another library's functions

doc/source/contributing_docstring.rst

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ Next example gives an idea on how a docstring looks like:
4747
4848
Examples
4949
--------
50-
>>> add(2, 2)
50+
>>> add(2, 2) # noqa F821
5151
4
52-
>>> add(25, 0)
52+
>>> add(25, 0) # noqa F821
5353
25
54-
>>> add(10, -10)
54+
>>> add(10, -10) # noqa F821
5555
0
5656
"""
5757
return num1 + num2
@@ -187,7 +187,7 @@ infinitive verb.
187187

188188
.. code-block:: python
189189
190-
def astype(dtype):
190+
def astype(dtype): # noqa F811
191191
"""
192192
Casts Series type.
193193
@@ -197,7 +197,7 @@ infinitive verb.
197197
198198
.. code-block:: python
199199
200-
def astype(dtype):
200+
def astype(dtype): # noqa F811
201201
"""
202202
Method to cast Series type.
203203
@@ -207,7 +207,7 @@ infinitive verb.
207207
208208
.. code-block:: python
209209
210-
def astype(dtype):
210+
def astype(dtype): # noqa F811
211211
"""
212212
Cast Series type
213213
@@ -217,7 +217,7 @@ infinitive verb.
217217
218218
.. code-block:: python
219219
220-
def astype(dtype):
220+
def astype(dtype): # noqa F811
221221
"""
222222
Cast Series type from its current type to the new type defined in
223223
the parameter dtype.
@@ -322,7 +322,7 @@ would be used, then we will specify "str, int or None, default None".
322322

323323
.. code-block:: python
324324
325-
class Series:
325+
class Series: # noqa F811
326326
def plot(self, kind, **kwargs):
327327
"""
328328
Generate a plot.
@@ -457,12 +457,14 @@ For example, with a single value:
457457
float
458458
Random number generated.
459459
"""
460-
return random.random()
460+
return np.random.random()
461461
462462
With more than one value:
463463

464464
.. code-block:: python
465465
466+
import string
467+
466468
def random_letters():
467469
"""
468470
Generate and return a sequence of random letters.
@@ -477,8 +479,8 @@ With more than one value:
477479
letters : str
478480
String of random letters.
479481
"""
480-
length = random.randint(1, 10)
481-
letters = ''.join(random.choice(string.ascii_lowercase)
482+
length = np.random.randint(1, 10)
483+
letters = ''.join(np.random.choice(string.ascii_lowercase)
482484
for i in range(length))
483485
return length, letters
484486
@@ -499,7 +501,7 @@ If the method yields its value:
499501
Random number generated.
500502
"""
501503
while True:
502-
yield random.random()
504+
yield np.random.random()
503505
504506
.. _docstring.see_also:
505507

@@ -558,7 +560,7 @@ For example:
558560

559561
.. code-block:: python
560562
561-
class Series:
563+
class Series: # noqa F811
562564
def head(self):
563565
"""
564566
Return the first 5 elements of the Series.
@@ -776,7 +778,7 @@ positional arguments ``head(3)``.
776778
777779
Examples
778780
--------
779-
>>> s = pd.Series('Antelope', 'Lion', 'Zebra', numpy.nan)
781+
>>> s = pd.Series('Antelope', 'Lion', 'Zebra', np.nan)
780782
>>> s.contains(pattern='a')
781783
0 False
782784
1 False
@@ -834,7 +836,7 @@ positional arguments ``head(3)``.
834836
--------
835837
>>> import numpy as np
836838
>>> import pandas as pd
837-
>>> df = pd.DataFrame(numpy.random.randn(3, 3),
839+
>>> df = pd.DataFrame(np.random.randn(3, 3),
838840
... columns=('a', 'b', 'c'))
839841
>>> df.method(1)
840842
21
@@ -909,7 +911,7 @@ plot will be generated automatically when building the documentation.
909911

910912
.. code-block:: python
911913
912-
class Series:
914+
class Series: # noqa F811
913915
def plot(self):
914916
"""
915917
Generate a plot with the `Series` data.
@@ -953,15 +955,15 @@ substitute the children's class names in this docstring.
953955
954956
955957
class ChildA(Parent):
956-
@Substitution(klass="ChildA")
957-
@Appender(Parent.my_function.__doc__)
958+
@Substitution(klass="ChildA") # noqa F821
959+
@Appender(Parent.my_function.__doc__) # noqa F821
958960
def my_function(self):
959961
...
960962
961963
962964
class ChildB(Parent):
963-
@Substitution(klass="ChildB")
964-
@Appender(Parent.my_function.__doc__)
965+
@Substitution(klass="ChildB") # noqa F821
966+
@Appender(Parent.my_function.__doc__) # noqa F821
965967
def my_function(self):
966968
...
967969
@@ -990,7 +992,7 @@ You can substitute and append in one shot with something like
990992

991993
.. code-block:: python
992994
993-
@Appender(template % _shared_doc_kwargs)
995+
@Appender(template % _shared_doc_kwargs) # noqa F821
994996
def my_function(self):
995997
...
996998

0 commit comments

Comments
 (0)