chunks¶
- emlib.numpytools.chunks(data, chunksize, hop=None, padwith=None)[source]¶
Iterate over data in chunks of chunksize. Returns a generator
- Parameters:
data (
ndarray) – the array to be iterated in chunkschunksize (
int) – the size of each chunkhop (
Optional[int]) – the amount of elements to skip between chunks, None to use chunksize as hop sizepadwith (
Union[float,int,None]) – value to pad when a chunk is not big enough, None to avoid padding. The type depends on the data type of the given array
- Return type:
Iterator[ndarray]- Returns:
a generator with chunks of data of chunksize or less