Skip to content

Commit 1fe7aa8

Browse files
WIP: Adding first docstrings checks to the CI
1 parent 28a42da commit 1fe7aa8

File tree

5 files changed

+39
-30
lines changed

5 files changed

+39
-30
lines changed

ci/code_checks.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
echo "inside $0"
1818
[[ $LINT ]] || { echo "NOT Linting. To lint use: LINT=true $0 $1"; exit 0; }
19-
[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "doctests" ]] || { echo "Unknown command $1. Usage: $0 [lint|patterns|doctests]"; exit 9999; }
19+
[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "docstrings" ]] || { echo "Unknown command $1. Usage: $0 [lint|patterns|docstrings]"; exit 9999; }
2020

2121
source activate pandas
2222
RET=0
@@ -126,9 +126,11 @@ if mods:
126126

127127
fi
128128

129-
### DOCTESTS ###
129+
### DOCSTRINGS ###
130130
if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
131131

132+
# Doctests
133+
132134
MSG='Doctests frame.py' ; echo $MSG
133135
pytest -q --doctest-modules pandas/core/frame.py \
134136
-k"-axes -combine -itertuples -join -nunique -pivot_table -quantile -query -reindex -reindex_axis -replace -round -set_index -stack -to_stata"
@@ -160,6 +162,11 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
160162
-k"-from_arrays -from_breaks -from_intervals -from_tuples -get_loc -set_closed -to_tuples -interval_range"
161163
RET=$(($RET + $?)) ; echo $MSG "DONE"
162164

165+
# Validate docstrings
166+
MSG='Validate docstrings (SS04, EX04)' ; echo $MSG
167+
scripts/validate_docstrings.py --errors=SS04,EX04
168+
RET=$(($RET + $?)) ; echo $MSG "DONE"
169+
163170
fi
164171

165172
exit $RET

pandas/core/frame.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -864,12 +864,17 @@ def iterrows(self):
864864
data types, the iterator returns a copy and not a view, and writing
865865
to it will have no effect.
866866
867-
Returns
868-
-------
867+
Yields
868+
------
869+
index : label or tuple of label
870+
The index of the row. A tuple for a `MultiIndex`.
871+
data : Series
872+
The data of the row as a Series.
873+
869874
it : generator
870875
A generator that iterates over the rows of the frame.
871876
872-
See also
877+
See Also
873878
--------
874879
itertuples : Iterate over DataFrame rows as namedtuples of the values.
875880
iteritems : Iterate over (column name, Series) pairs.
@@ -3940,6 +3945,10 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
39403945
necessary. Setting to False will improve the performance of this
39413946
method
39423947
3948+
Returns
3949+
-------
3950+
DataFrame
3951+
39433952
Examples
39443953
--------
39453954
>>> df = pd.DataFrame({'month': [1, 4, 7, 10],
@@ -3980,10 +3989,6 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
39803989
2 2014 4 40
39813990
3 2013 7 84
39823991
4 2014 10 31
3983-
3984-
Returns
3985-
-------
3986-
dataframe : DataFrame
39873992
"""
39883993
inplace = validate_bool_kwarg(inplace, 'inplace')
39893994
if not isinstance(keys, list):
@@ -6683,6 +6688,15 @@ def round(self, decimals=0, *args, **kwargs):
66836688
of `decimals` which are not columns of the input will be
66846689
ignored.
66856690
6691+
Returns
6692+
-------
6693+
DataFrame
6694+
6695+
See Also
6696+
--------
6697+
numpy.around
6698+
Series.round
6699+
66866700
Examples
66876701
--------
66886702
>>> df = pd.DataFrame(np.random.random([3, 3]),
@@ -6708,15 +6722,6 @@ def round(self, decimals=0, *args, **kwargs):
67086722
first 0.0 1 0.17
67096723
second 0.0 1 0.58
67106724
third 0.9 0 0.49
6711-
6712-
Returns
6713-
-------
6714-
DataFrame object
6715-
6716-
See Also
6717-
--------
6718-
numpy.around
6719-
Series.round
67206725
"""
67216726
from pandas.core.reshape.concat import concat
67226727

@@ -6782,7 +6787,6 @@ def corr(self, method='pearson', min_periods=1):
67826787
67836788
Examples
67846789
--------
6785-
>>> import numpy as np
67866790
>>> histogram_intersection = lambda a, b: np.minimum(a, b
67876791
... ).sum().round(decimals=1)
67886792
>>> df = pd.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)],

pandas/core/generic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9622,8 +9622,7 @@ def nanptp(values, axis=0, skipna=True):
96229622

96239623
cls.ptp = _make_stat_function(
96249624
cls, 'ptp', name, name2, axis_descr,
9625-
"""
9626-
Returns the difference between the maximum value and the
9625+
"""Returns the difference between the maximum value and the
96279626
minimum value in the object. This is the equivalent of the
96289627
``numpy.ndarray`` method ``ptp``.
96299628

pandas/core/panel.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ def panel_index(time, panels, names=None):
106106

107107
class Panel(NDFrame):
108108
"""
109-
Represents wide format panel data, stored as 3-dimensional array
110-
111-
.. deprecated:: 0.20.0
112-
The recommended way to represent 3-D data are with a MultiIndex on a
113-
DataFrame via the :attr:`~Panel.to_frame()` method or with the
114-
`xarray package <http://xarray.pydata.org/en/stable/>`__.
115-
Pandas provides a :attr:`~Panel.to_xarray()` method to automate this
116-
conversion.
109+
Represents wide format panel data, stored as 3-dimensional array.
110+
111+
.. deprecated:: 0.20.0
112+
The recommended way to represent 3-D data are with a MultiIndex on a
113+
DataFrame via the :attr:`~Panel.to_frame()` method or with the
114+
`xarray package <http://xarray.pydata.org/en/stable/>`__.
115+
Pandas provides a :attr:`~Panel.to_xarray()` method to automate this
116+
conversion.
117117
118118
Parameters
119119
----------

pandas/core/series.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,6 @@ def corr(self, other, method='pearson', min_periods=None):
19131913
19141914
Examples
19151915
--------
1916-
>>> import numpy as np
19171916
>>> histogram_intersection = lambda a, b: np.minimum(a, b
19181917
... ).sum().round(decimals=1)
19191918
>>> s1 = pd.Series([.2, .0, .6, .2])

0 commit comments

Comments
 (0)