Move folders
This commit is contained in:
parent
ba2e252759
commit
3cf28379e8
89 changed files with 47 additions and 31 deletions
17
src/great_ai/utilities/chunk.py
Normal file
17
src/great_ai/utilities/chunk.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from typing import Iterable, List, TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def chunk(values: Iterable[T], chunk_size: int) -> Iterable[T]:
|
||||
assert chunk_size >= 1
|
||||
|
||||
result: List[T] = []
|
||||
for v in values:
|
||||
result.append(v)
|
||||
if len(result) == chunk_size:
|
||||
yield result
|
||||
result = []
|
||||
|
||||
if len(result) > 0:
|
||||
yield result
|
||||
Loading…
Add table
Add a link
Reference in a new issue