Skip to content

Commit

Permalink
DOC Ensures that if_delegate_has_method passes numpydoc validation (#…
Browse files Browse the repository at this point in the history
…24633)

Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
  • Loading branch information
3 people committed Oct 13, 2022
1 parent aa7fd7a commit 0c8820b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion sklearn/tests/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

FUNCTION_DOCSTRING_IGNORE_LIST = [
"sklearn.utils.extmath.fast_logdet",
"sklearn.utils.metaestimators.if_delegate_has_method",
]
FUNCTION_DOCSTRING_IGNORE_LIST = set(FUNCTION_DOCSTRING_IGNORE_LIST)

Expand Down
13 changes: 9 additions & 4 deletions sklearn/utils/metaestimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,27 @@ def _check(self, obj):

# TODO(1.3) remove
def if_delegate_has_method(delegate):
"""Create a decorator for methods that are delegated to a sub-estimator
This enables ducktyping by hasattr returning True according to the
sub-estimator.
"""Create a decorator for methods that are delegated to a sub-estimator.
.. deprecated:: 1.3
`if_delegate_has_method` is deprecated in version 1.1 and will be removed in
version 1.3. Use `available_if` instead.
This enables ducktyping by hasattr returning True according to the
sub-estimator.
Parameters
----------
delegate : str, list of str or tuple of str
Name of the sub-estimator that can be accessed as an attribute of the
base object. If a list or a tuple of names are provided, the first
sub-estimator that is an attribute of the base object will be used.
Returns
-------
callable
Callable makes the decorated method available if the delegate
has a method with the same name as the decorated method.
"""
if isinstance(delegate, list):
delegate = tuple(delegate)
Expand Down

0 comments on commit 0c8820b

Please sign in to comment.