Convert `supervision/utils/iterables.py` docstrings to doctests
--- Co-authored-by: copilot-swe-agent[bot] <198982749+copilot@users.noreply.github.com>
This commit is contained in:
parent
566844f591
commit
cda79458a9
|
|
@ -22,13 +22,11 @@ def create_batches(
|
|||
the input `sequence`.
|
||||
|
||||
Examples:
|
||||
```python
|
||||
list(create_batches([1, 2, 3, 4, 5], 2))
|
||||
# [[1, 2], [3, 4], [5]]
|
||||
|
||||
list(create_batches("abcde", 3))
|
||||
# [['a', 'b', 'c'], ['d', 'e']]
|
||||
```
|
||||
>>> from supervision.utils.iterables import create_batches
|
||||
>>> list(create_batches([1, 2, 3, 4, 5], 2))
|
||||
[[1, 2], [3, 4], [5]]
|
||||
>>> list(create_batches("abcde", 3))
|
||||
[['a', 'b', 'c'], ['d', 'e']]
|
||||
"""
|
||||
batch_size = max(batch_size, 1)
|
||||
current_batch: list[V] = []
|
||||
|
|
@ -58,13 +56,11 @@ def fill(sequence: list[V], desired_size: int, content: V) -> list[V]:
|
|||
A padded version of the input `sequence` (if needed).
|
||||
|
||||
Examples:
|
||||
```python
|
||||
fill([1, 2], 4, 0)
|
||||
# [1, 2, 0, 0]
|
||||
|
||||
fill(['a', 'b'], 3, 'c')
|
||||
# ['a', 'b', 'c']
|
||||
```
|
||||
>>> from supervision.utils.iterables import fill
|
||||
>>> fill([1, 2], 4, 0)
|
||||
[1, 2, 0, 0]
|
||||
>>> fill(['a', 'b'], 3, 'c')
|
||||
['a', 'b', 'c']
|
||||
"""
|
||||
missing_size = max(0, desired_size - len(sequence))
|
||||
sequence.extend([content] * missing_size)
|
||||
|
|
|
|||
Loading…
Reference in New Issue