window_padded¶
- emlib.iterlib.window_padded(seq, size=3, step=1, paddingval=None)[source]¶
Similar to window, but the last window will be padded
- Parameters:
seq (
Iterable[TypeVar(T)]) – the sequencesize – the size of each window
step – how much to advance the window each iteration
paddingval – value used to pad the last iteration if there are not enough items
- Return type:
Iterator[tuple[TypeVar(T),...]]- Returns:
an iterator of tuples, where each tuple has size elements
Example
>>> list(windowed([1, 2, 3, 4, 5, 6], 3, 2)) [(1, 2, 3), (3, 4, 5), (5, None, None)]