8000 DOC Ensures that sklearn.base.clone passes numpydoc validation (#21557) · scikit-learn/scikit-learn@d180184 · GitHub
[go: up one dir, main page]

Skip to content

Commit d180184

Browse files
DOC Ensures that sklearn.base.clone passes numpydoc validation (#21557)
* sklearn clone numpydoc validation fix * adjusting docstring and reverting earlier unrelated change * Update sklearn/base.py Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com> * Update sklearn/base.py Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com> Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
1 parent d017f6f commit d180184

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
numpydoc_validation = pytest.importorskip("numpydoc.validate")
1313

1414
FUNCTION_DOCSTRING_IGNORE_LIST = [
15-
"sklearn.base.clone",
1615
"sklearn.cluster._affinity_propagation.affinity_propagation",
1716
"sklearn.cluster._kmeans.kmeans_plusplus",
1817
"sklearn.cluster._mean_shift.estimate_bandwidth",

sklearn/base.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,34 @@
3131

3232

3333
def clone(estimator, *, safe=True):
34-
"""Constructs a new unfitted estimator with the same parameters.
34+
"""Construct a new unfitted estimator with the same parameters.
3535
3636
Clone does a deep copy of the model in an estimator
37-
without actually copying attached data. It yields a new estimator
37+
without actually copying attached data. It returns a new estimator
3838
with the same parameters that has not been fitted on any data.
3939
40-
If the estimator's `random_state` parameter is an integer (or if the
41-
estimator doesn't have a `random_state` parameter), an *exact clone* is
42-
returned: the clone and the original estimator will give the exact same
43-
results. Otherwise, *statistical clone* is returned: the clone might
44-
yield different results from the original estimator. More details can be
45-
found in :ref:`randomness`.
46-
4740
Parameters
4841
----------
4942
estimator : {list, tuple, set} of estimator instance or a single \
5043
estimator instance
5144
The estimator or group of estimators to be cloned.
52-
5345
safe : bool, default=True
5446
If safe is False, clone will fall back to a deep copy on objects
5547
that are not estimators.
5648
49+
Returns
50+
-------
51+
estimator : object
52+
The deep copy of the input, an estimator if input is an estimator.
53+
54+
Notes
55+
-----
56+
If the estimator's `random_state` parameter is an integer (or if the
57+
estimator doesn't have a `random_state` parameter), an *exact clone* is
58+
returned: the clone and the original estimator will give the exact same
59+
results. Otherwise, *statistical clone* is returned: the clone might
60+
return different results from the original estimator. More details can be
61+
found in :ref:`randomness`.
5762
"""
5863
estimator_type = type(estimator)
5964
# XXX: not handling dictionaries

0 commit comments

Comments
 (0)
0