rangelist
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.
Classes:
| Name | Description |
|---|---|
RangeList |
Class for manipulating a list of range intervals. |
RangeList
¶
Class for manipulating a list of range intervals. Each range interval in the list is a [start, end)-tuple.
Methods:
| Name | Description |
|---|---|
add |
Add a single value, merges to last range if contiguous. |
cut |
Return a pair of lists with everything before/after cut. |
cut_ |
Return a pair of lists with everything before/after cut. |
cut_range |
Return three lists, everthing before/within/after cut range. |
insert |
Add a new range, merging to adjacent/overlapping ranges as appropriate. |
insert_list |
Add each range from a list of ranges. |
join_ |
Return a single list that includes all lists in input list. |
join_pair_ |
Return a single pair of lists that joins two input lists. |
remove |
Remove everything that overlaps with given range. |
Attributes:
| Name | Type | Description |
|---|---|---|
end |
Returns the end value of range (or None if empty). |
|
is_empty |
Returns True if the list is empty. |
|
list |
Returns the list of ranges. |
|
start |
Return the start value of range (or None if empty). |
Source code in sleap/rangelist.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
end
property
¶
Returns the end value of range (or None if empty).
is_empty
property
¶
Returns True if the list is empty.
list
property
writable
¶
Returns the list of ranges.
start
property
¶
Return the start value of range (or None if empty).
add(val, tolerance=0)
¶
Add a single value, merges to last range if contiguous.
Source code in sleap/rangelist.py
52 53 54 55 56 57 | |
cut(cut)
¶
Return a pair of lists with everything before/after cut.
Source code in sleap/rangelist.py
78 79 80 | |
cut_(range_list, cut)
staticmethod
¶
Return a pair of lists with everything before/after cut. Args: range_list: the list to cut cut: the value at which to cut list Returns: (pre-cut list, post-cut list)-tuple
Source code in sleap/rangelist.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
cut_range(cut)
¶
Return three lists, everthing before/within/after cut range.
Source code in sleap/rangelist.py
82 83 84 85 86 87 88 89 90 91 | |
insert(new_range)
¶
Add a new range, merging to adjacent/overlapping ranges as appropriate.
Source code in sleap/rangelist.py
59 60 61 62 63 64 65 | |
insert_list(range_list)
¶
Add each range from a list of ranges.
Source code in sleap/rangelist.py
67 68 69 70 71 | |
join_(list_list)
classmethod
¶
Return a single list that includes all lists in input list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
list_list
|
List[List[Tuple[int]]]
|
a list of range lists |
required |
Source code in sleap/rangelist.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
join_pair_(list_a, list_b)
staticmethod
¶
Return a single pair of lists that joins two input lists.
Source code in sleap/rangelist.py
140 141 142 143 144 145 146 147 148 149 150 151 | |
remove(remove)
¶
Remove everything that overlaps with given range.
Source code in sleap/rangelist.py
73 74 75 76 | |