tracktable.script_helpers module

Submodules

Module contents

Tracktable Trajectory Toolkit - Helper functions for creating scripts

tracktable.script_helpers.n_at_a_time(iterable, howmany, fillvalue=None)[source]

Collect data into fixed-length chunks or blocks

This function is an adapter for an iterable that returns objects N at a time instead of one at a time.

Example

>>> list(n_at_a_time(range(10), 3, -1))
[(0, 1, 2), (3, 4, 5), (6, 7, 8), (9, -1, -1)]
Args:

iterable {sequence}: Data source howmany {int}: How many elements to take at a time fillvalue {any}: Value to pad with if the iterable runs out

Returns:

New sequence whose elements are tuples of elements from the original iterable