interval_masks

function of dascore.utils.intervals source

interval_masks(
    values ,
    intervals ,
)-> ‘list[np.ndarray]’

Return, per interval, the mask of values that interval covers.

Coverage is half-open, [start, end), with one exception: the end of a coverage run belongs to the interval ending there when no half-open interval claims it, so the last point of a run is not left out. Point markers (equal start and end) cover nothing.

Parameters

Parameter Description
values The values, along the interval axis, to test for coverage.
intervals A sequence of (start, end) pairs.

Examples

from dascore.utils.intervals import interval_masks
masks = interval_masks([0, 1, 2, 3], [(0, 2), (2, 3)])
masks[0]
masks[1]  # the run ends at 3, so 3 is not left uncovered
array([False, False,  True,  True])