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 chunks

  • chunksize (int) – the size of each chunk

  • hop (Optional[int]) – the amount of elements to skip between chunks

  • padwith (Optional[int]) – value to pad when a chunk is not big enough, None to avoid padding

Return type:

Iterator[ndarray]

Returns:

a generator with chunks of data of chunksize or less