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
|
"""Utilities for docstring in imbalanced-learn."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# 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):
if obj.__doc__:
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()
|