rxn.utilities.containers.chunker
- rxn.utilities.containers.chunker(iterable, chunk_size, fill_value=<object object>)[source]
Iterate through an iterable in chunks of given size.
Adapted from “grouper” function in the itertools documentation: https://docs.python.org/3/library/itertools.html#itertools-recipes
- Parameters
iterable (
Iterable
[TypeVar
(T
)]) – some iterable to create chunks from.chunk_size (
int
) – size of the chunks.fill_value (
TypeVar
(T
), default:<object object at 0x7f9347851f90>
) – value to fill in if the last chunk is too small. If nothing is specified, the last chunk may be smaller.
- Return type
Generator
[List
[TypeVar
(T
)],None
,None
]- Returns
Iterator over lists representing the chunks.