Skip to content

[MRG + 1 (rv) + 1 (alex) + 1] Add a check to test the docstring params and their order #9206

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 77 commits into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
3ae41ff
add test script to have docstrings consistent with function signatures
agramfort Jun 6, 2017
3a1b925
fix docstrings in datasets
agramfort Jun 6, 2017
04da883
add tests
agramfort Jun 7, 2017
00ebcfc
update travis
agramfort Jun 7, 2017
0b2c0eb
refactor
agramfort Jun 7, 2017
5495e0e
make travis happy?
agramfort Jun 8, 2017
f3cefca
do not crash when y=None for API reason
agramfort Jun 8, 2017
a755044
more fixes
agramfort Jun 8, 2017
9fa05d8
more on metrics module
agramfort Jun 8, 2017
f3d9c11
more
agramfort Jun 8, 2017
42b2a2d
more
agramfort Jun 8, 2017
98686e4
more
agramfort Jun 8, 2017
46abcd8
more
agramfort Jun 8, 2017
27936f4
more
agramfort Jun 9, 2017
88c71f3
more
agramfort Jun 9, 2017
c0a0630
more
agramfort Jun 9, 2017
d48d425
more
agramfort Jun 9, 2017
cd36d2d
more
agramfort Jun 9, 2017
4183f6a
more
agramfort Jun 9, 2017
a15459d
more
agramfort Jun 10, 2017
9a6f01d
more
agramfort Jun 10, 2017
ed1a350
Merge master
raghavrv Jun 16, 2017
48f7433
Merge pull request #15 from raghavrv/test_docstring_params
agramfort Jun 18, 2017
b93b4cc
Merge branch 'master' into test_docstring
raghavrv Jun 18, 2017
440231f
Merge branch 'master' into test_docstring
raghavrv Jun 23, 2017
d098674
No need of TEST_DOCSTRING='false'
raghavrv Jun 23, 2017
a1bbd53
Flake8 and licence
raghavrv Jun 23, 2017
b092418
Add Alex's name to the authors
raghavrv Jun 23, 2017
5a104ca
Moving docstring parameter test to sklearn/tests
raghavrv Jun 23, 2017
1f51107
Try fixing some of the inconsistencies
raghavrv Jun 23, 2017
c093014
Remove 'optional' to keep it under 80chars
raghavrv Jun 23, 2017
575b243
Address flake8 in least_angle.py
raghavrv Jun 23, 2017
3e2d837
Fix more inconsistencies
raghavrv Jun 23, 2017
8b8ce12
Fix rest of the inconsistencies
raghavrv Jun 23, 2017
da187d5
Merge branch 'master' into test_docstring
raghavrv Jun 23, 2017
bb554c7
Fix rest of the docstrings; Add debug statements
raghavrv Jun 24, 2017
9ba1682
Collapse the two Notes section into one
raghavrv Jun 25, 2017
8ab87a9
Print class names properly even for decorated class methods
raghavrv Jun 26, 2017
6bb55fb
Fix doc inconsistencies in ExtraTree*
raghavrv Jun 26, 2017
e92b1b8
Add some debug statements
raghavrv Jun 26, 2017
7d456a7
Test only on python3.5
raghavrv Jun 26, 2017
140bbb7
Remove debug statements
raghavrv Jun 26, 2017
b71fe7e
Fix flake8
raghavrv Jun 26, 2017
657dca9
Fix up Olivier's comments; Add TODO comment
raghavrv Jun 28, 2017
ecf22f3
Add ignore warnings
raghavrv Jun 28, 2017
d308257
TST also check for incorrect parameter type definitions
raghavrv Jun 28, 2017
f65861a
ENH Distinguish between no space before colon and empty type definition
raghavrv Jun 28, 2017
9d95cf8
Merge branch 'master' into test_docstring
raghavrv Jun 28, 2017
0cf439d
TST the test functions ;)
raghavrv Jun 28, 2017
57e4109
Fix new doc inconsistencies after merging with master
raghavrv Jun 28, 2017
ac8ecfd
FIX doc param definition inconsistencies
raghavrv Jun 28, 2017
d619987
MERGE with latest master
raghavrv Jun 28, 2017
70317cd
FIX error message to include sag
raghavrv Jun 29, 2017
89a2b0e
Fix incorrect merge
raghavrv Jun 29, 2017
efd4a8d
FIX remove assert_true
raghavrv Jun 29, 2017
a8f281c
Use walk_packages to find the modules to check docstrings in
raghavrv Jun 30, 2017
e7f61c7
ENH Automatically identify deprecated classes/methods/functions
raghavrv Jun 30, 2017
dffc5fc
ENH add _is_deprecated and tests for the same in utils
raghavrv Jun 30, 2017
6788174
TST Use importlib
raghavrv Jun 30, 2017
0e2c56a
FIX address Andy's comments
raghavrv Jul 3, 2017
11bc8c0
ENH Use symmetric_difference for comparison
raghavrv Jul 3, 2017
aaa6770
Address Andy's comments
raghavrv Jul 3, 2017
fcf5538
Skip test for builds which have python <= 3.5
raghavrv Jul 3, 2017
6319bf6
Skip both tests
raghavrv Jul 4, 2017
d3ab240
Make _is_deprecated work in python2.7
raghavrv Jul 6, 2017
e4e1f6c
FIX up the tests to include predict_log_proba
raghavrv Jul 6, 2017
c4c30fe
Fix typo in _is_deprecated logic
raghavrv Jul 6, 2017
fe54c93
FIX tests shouldn't separately test for __call__. It's included while…
raghavrv Jul 6, 2017
e1bc4c1
Remove redundant _DOC_SPECIAL_MEMBERS
raghavrv Jul 6, 2017
1465605
Skip _is_deprecated and it's tests for < python3.5
raghavrv Jul 6, 2017
631d0c5
Flake8
raghavrv Jul 6, 2017
ff2bf8c
Merge branch 'master' into test_docstring
raghavrv Jul 6, 2017
5b19ae8
Merge branch 'master' into test_docstring
jnothman Jul 8, 2017
f5192da
ENH address joel's comments
raghavrv Jul 9, 2017
cb25e5e
Merge branch 'test_docstring' of github.com:raghavrv/scikit-learn int…
raghavrv Jul 9, 2017
7e3e2ca
Address the rest of the comments
raghavrv Jul 10, 2017
ed2f75d
Merge branch 'master' into test_docstring
raghavrv Jul 11, 2017
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ matrix:
- env: RUN_FLAKE8="true" SKIP_TESTS="true"
DISTRIB="conda" PYTHON_VERSION="3.5" INSTALL_MKL="true"
NUMPY_VERSION="1.12.1" SCIPY_VERSION="0.19.0" CYTHON_VERSION="0.23.5"
TEST_DOCSTRINGS="true"
# This environment tests scikit-learn against numpy and scipy master
# installed from their CI wheels in a virtualenv with the Python
# interpreter provided by travis.
Expand Down
4 changes: 4 additions & 0 deletions build_tools/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ if [[ "$COVERAGE" == "true" ]]; then
pip install coverage codecov
fi

if [[ "$TEST_DOCSTRINGS" == "true" ]]; then
pip install sphinx numpydoc # numpydoc requires sphinx
Copy link
Member

Choose a reason for hiding this comment

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

omg we're using actual numpydoc! Horray!

fi

if [[ "$SKIP_TESTS" == "true" ]]; then
echo "No need to build scikit-learn when not running the tests"
else
Expand Down
52 changes: 49 additions & 3 deletions sklearn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,11 @@ def get_indices(self, i):

Only works if ``rows_`` and ``columns_`` attributes exist.

Parameters
----------
i : int
The index of the cluster.

Returns
-------
row_ind : np.array, dtype=np.intp
Expand All @@ -443,6 +448,11 @@ def get_indices(self, i):
def get_shape(self, i):
"""Shape of the i'th bicluster.

Parameters
----------
i : int
The index of the cluster.

Returns
-------
shape : (int, int)
Expand All @@ -454,9 +464,22 @@ def get_shape(self, i):
def get_submatrix(self, i, data):
"""Returns the submatrix corresponding to bicluster `i`.

Parameters
----------
i : int
The index of the cluster.
data : array
The data.

Returns
-------
submatrix : array
The submatrix corresponding to bicluster i.

Notes
-----
Works with sparse matrices. Only works if ``rows_`` and
``columns_`` attributes exist.

"""
from .utils.validation import check_array
data = check_array(data, accept_sparse='csr')
Expand Down Expand Up @@ -525,10 +548,33 @@ class MetaEstimatorMixin(object):
###############################################################################

def is_classifier(estimator):
"""Returns True if the given estimator is (probably) a classifier."""
"""Returns True if the given estimator is (probably) a classifier.

Parameters
----------
estimator : object
Estimator object to test.

Returns
-------
out : bool
True if estimator is a classifier and False otherwise.
"""
return getattr(estimator, "_estimator_type", None) == "classifier"


def is_regressor(estimator):
"""Returns True if the given estimator is (probably) a regressor."""
"""Returns True if the given estimator is (probably) a regressor.


Parameters
----------
estimator : object
Estimator object to test.

Returns
-------
out : bool
True if estimator is a regressor and False otherwise.
"""
return getattr(estimator, "_estimator_type", None) == "regressor"
6 changes: 3 additions & 3 deletions sklearn/cluster/affinity_propagation_.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ class AffinityPropagation(BaseEstimator, ClusterMixin):
damping : float, optional, default: 0.5
Damping factor between 0.5 and 1.

max_iter : int, optional, default: 200
Maximum number of iterations.

convergence_iter : int, optional, default: 15
Number of iterations with no change in the number
of estimated clusters that stops the convergence.

max_iter : int, optional, default: 200
Maximum number of iterations.

copy : boolean, optional, default: True
Make a copy of input data.

Expand Down
35 changes: 19 additions & 16 deletions sklearn/cluster/hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ def linkage_tree(X, connectivity=None, n_components=None,
be symmetric and only the upper triangular half is used.
Default is None, i.e, the Ward algorithm is unstructured.

n_components : int (optional)
Copy link
Member

Choose a reason for hiding this comment

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

This parameter is unused. See #9307

Copy link
Member Author

Choose a reason for hiding this comment

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

(You don't want this addressed in this PR right?)

The number of connected components in the graph.

n_clusters : int (optional)
Stop early the construction of the tree at n_clusters. This is
useful to decrease computation time if the number of clusters is
Expand Down Expand Up @@ -596,14 +599,6 @@ class AgglomerativeClustering(BaseEstimator, ClusterMixin):
n_clusters : int, default=2
The number of clusters to find.

connectivity : array-like or callable, optional
Connectivity matrix. Defines for each sample the neighboring
samples following a given structure of the data.
This can be a connectivity matrix itself or a callable that transforms
the data into a connectivity matrix, such as derived from
kneighbors_graph. Default is None, i.e, the
hierarchical clustering algorithm is unstructured.

affinity : string or callable, default: "euclidean"
Metric used to compute the linkage. Can be "euclidean", "l1", "l2",
"manhattan", "cosine", or 'precomputed'.
Expand All @@ -615,6 +610,14 @@ class AgglomerativeClustering(BaseEstimator, ClusterMixin):
By default, no caching is done. If a string is given, it is the
path to the caching directory.

connectivity : array-like or callable, optional
Connectivity matrix. Defines for each sample the neighboring
samples following a given structure of the data.
This can be a connectivity matrix itself or a callable that transforms
the data into a connectivity matrix, such as derived from
kneighbors_graph. Default is None, i.e, the
hierarchical clustering algorithm is unstructured.

compute_full_tree : bool or 'auto' (optional)
Stop early the construction of the tree at n_clusters. This is
useful to decrease computation time if the number of clusters is
Expand Down Expand Up @@ -766,14 +769,6 @@ class FeatureAgglomeration(AgglomerativeClustering, AgglomerationTransform):
n_clusters : int, default 2
The number of clusters to find.

connectivity : array-like or callable, optional
Connectivity matrix. Defines for each feature the neighboring
features following a given structure of the data.
This can be a connectivity matrix itself or a callable that transforms
the data into a connectivity matrix, such as derived from
kneighbors_graph. Default is None, i.e, the
hierarchical clustering algorithm is unstructured.

affinity : string or callable, default "euclidean"
Metric used to compute the linkage. Can be "euclidean", "l1", "l2",
"manhattan", "cosine", or 'precomputed'.
Expand All @@ -785,6 +780,14 @@ class FeatureAgglomeration(AgglomerativeClustering, AgglomerationTransform):
By default, no caching is done. If a string is given, it is the
path to the caching directory.

connectivity : array-like or callable, optional
Connectivity matrix. Defines for each feature the neighboring
features following a given structure of the data.
This can be a connectivity matrix itself or a callable that transforms
the data into a connectivity matrix, such as derived from
kneighbors_graph. Default is None, i.e, the
hierarchical clustering algorithm is unstructured.

compute_full_tree : bool or 'auto', optional, default "auto"
Stop early the construction of the tree at n_clusters. This is
useful to decrease computation time if the number of clusters is
Expand Down
Loading