split_interval_at_values¶
- emlib.mathlib.split_interval_at_values(start, end, offsets)[source]¶
Split interval (start, end) at the given offsets
- Parameters:
start (
TypeVar(T,float,Fraction)) – start of the intervalend (
TypeVar(T,float,Fraction)) – end of the intervaloffsets (
Sequence[TypeVar(T,float,Fraction)]) – offsets to split the interval at. Must be sorted
- Return type:
list[tuple[TypeVar(T,float,Fraction),TypeVar(T,float,Fraction)]]- Returns:
a list of (start, end) segments where no segment extends over any of the given offsets
Example
>>> split_interval_at_values(1, 3, [1.5, 2]) [(1, 1.5), (1.5, 2), (2, 3)] >>> split_interval_at_values(0.2, 4.3, list(range(10))) [(0.2, 1), (1, 2), (2, 3), (3, 4), (4, 4.3)]