-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_docstring.py
50 lines (38 loc) · 1.74 KB
/
_docstring.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Utilities for docstring in imbalanced-learn."""
# Authors: Guillaume Lemaitre <[email protected]>
# License: MIT
class Substitution:
"""Decorate a function's or a class' docstring to perform string
substitution on it.
This decorator should be robust even if obj.__doc__ is None
(for example, if -OO was passed to the interpreter)
"""
def __init__(self, *args, **kwargs):
if args and kwargs:
raise AssertionError("Only positional or keyword args are allowed")
self.params = args or kwargs
def __call__(self, obj):
obj.__doc__ = obj.__doc__.format(**self.params)
return obj
_random_state_docstring = """random_state : int, RandomState instance, default=None
Control the randomization of the algorithm.
- If int, ``random_state`` is the seed used by the random number
generator;
- If ``RandomState`` instance, random_state is the random number
generator;
- If ``None``, the random number generator is the ``RandomState``
instance used by ``np.random``.
""".rstrip()
_n_jobs_docstring = """n_jobs : int, default=None
Number of CPU cores used during the cross-validation loop.
``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
``-1`` means using all processors. See
`Glossary <https://scikit-learn.org/stable/glossary.html#term-n-jobs>`_
for more details.
""".rstrip()
_validate_if_dask_collection_docstring = \
"""validate_if_dask_collection : bool, default=False
Whether or not `X` and `y` should be validated. This parameter applies
only when `X` and `y` are Dask collections where validation might be
potentially costly.
""".rstrip()