sleap.rangelist

Module with RangeList class for manipulating a list of range intervals.

This is used to cache the track occupancy so we can keep cache updating when user manipulates tracks for a range of instances.

class sleap.rangelist.RangeList(range_list: List[Tuple[int]] = None)[source]

Class for manipulating a list of range intervals. Each range interval in the list is a [start, end)-tuple.

add(val, tolerance=0)[source]

Add a single value, merges to last range if contiguous.

cut(cut: int)[source]

Return a pair of lists with everything before/after cut.

static cut_(range_list: List[Tuple[int]], cut: int)[source]

Return a pair of lists with everything before/after cut. :param range_list: the list to cut :param cut: the value at which to cut list

Returns

(pre-cut list, post-cut list)-tuple

cut_range(cut: tuple)[source]

Return three lists, everthing before/within/after cut range.

property end

Returns the end value of range (or None if empty).

insert(new_range: tuple)[source]

Add a new range, merging to adjacent/overlapping ranges as appropriate.

insert_list(range_list: List[Tuple[int]])[source]

Add each range from a list of ranges.

property is_empty

Returns True if the list is empty.

classmethod join_(list_list: List[List[Tuple[int]]])[source]

Return a single list that includes all lists in input list.

Parameters

list_list – a list of range lists

Returns

range list that joins all of the lists in list_list

static join_pair_(list_a: List[Tuple[int]], list_b: List[Tuple[int]])[source]

Return a single pair of lists that joins two input lists.

property list

Returns the list of ranges.

remove(remove: tuple)[source]

Remove everything that overlaps with given range.

property start

Return the start value of range (or None if empty).