Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ee0189

Browse files
authored
DOC Ensure that gen_even_slices passes numpydoc validation (#24608)
1 parent 8a86e21 commit 0ee0189

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

sklearn/tests/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"sklearn.utils.extmath.randomized_svd",
1717
"sklearn.utils.extmath.svd_flip",
1818
"sklearn.utils.gen_batches",
19-
"sklearn.utils.gen_even_slices",
2019
"sklearn.utils.metaestimators.if_delegate_has_method",
2120
]
2221
FUNCTION_DOCSTRING_IGNORE_LIST = set(FUNCTION_DOCSTRING_IGNORE_LIST)

sklearn/utils/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,21 +746,25 @@ def gen_batches(n, batch_size, *, min_batch_size=0):
746746

747747

748748
def gen_even_slices(n, n_packs, *, n_samples=None):
749-
"""Generator to create n_packs slices going up to n.
749+
"""Generator to create `n_packs` evenly spaced slices going up to `n`.
750+
751+
If `n_packs` does not divide `n`, except for the first `n % n_packs`
752+
slices, remaining slices may contain fewer elements.
750753
751754
Parameters
752755
----------
753756
n : int
757+
Size of the sequence.
754758
n_packs : int
755759
Number of slices to generate.
756760
n_samples : int, default=None
757-
Number of samples. Pass n_samples when the slices are to be used for
761+
Number of samples. Pass `n_samples` when the slices are to be used for
758762
sparse matrix indexing; slicing off-the-end raises an exception, while
759763
it works for NumPy arrays.
760764
761765
Yields
762766
------
763-
slice
767+
`slice` representing a set of indices from 0 to n.
764768
765769
See Also
766770
--------

0 commit comments

Comments
 (0)