Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 1 deletion sklearn/tests/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"sklearn.utils.extmath.randomized_svd",
"sklearn.utils.extmath.svd_flip",
"sklearn.utils.gen_batches",
"sklearn.utils.gen_even_slices",
"sklearn.utils.metaestimators.if_delegate_has_method",
]
FUNCTION_DOCSTRING_IGNORE_LIST = set(FUNCTION_DOCSTRING_IGNORE_LIST)
Expand Down
10 changes: 7 additions & 3 deletions sklearn/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,21 +746,25 @@ def gen_batches(n, batch_size, *, min_batch_size=0):


def gen_even_slices(n, n_packs, *, n_samples=None):
"""Generator to create n_packs slices going up to n.
"""Generator to create `n_packs` evenly spaced slices going up to `n`.
If `n_packs` does not divide `n`, except for the first `n % n_packs`
slices, remaining slices may contain fewer elements.
Parameters
----------
n : int
Size of the sequence.
n_packs : int
Number of slices to generate.
n_samples : int, default=None
Number of samples. Pass n_samples when the slices are to be used for
Number of samples. Pass `n_samples` when the slices are to be used for
sparse matrix indexing; slicing off-the-end raises an exception, while
it works for NumPy arrays.
Yields
------
slice
`slice` representing a set of indices from 0 to n.
See Also
--------
Expand Down