FrozenIntervalSet¶
-
class
part.
FrozenIntervalSet
(iterable=None)¶ Frozen Interval Set class.
The
FrozenIntervalSet
class (which inherits from theIntervalSet
class) is designed to hold frozen disjoint intervals.-
__init__
(iterable=None)¶ Initialize a
FrozenIntervalSet
instance.- Parameters
iterable (
Iterable
) –An optional iterable of:
Examples
>>> from part import FrozenIntervalSet >>> a = FrozenIntervalSet([2, (6, 7), (8, 9, None), (10, 11, True, True)]) >>> print(a) [2;2] | [6;7) | (8;9) | [10;11]
-
__hash__
()¶ A
FrozenIntervalSet
instance is hashable.It can be used as key in dictionaries.
-
__getitem__
(item)¶ Return the nth interval. The array access operator supports slicing.
- Parameters
- Returns
- Return type
The nth interval
- Raises
IndexError – If the item is out of range.
Examples
>>> from part import FrozenIntervalSet >>> a = FrozenIntervalSet([2, (6, 7), (8, 9, None), (10, 11, True, True)]) >>> print(a[0]) [2;2] >>> print(a[2]) (8;9) >>> print(a[2]) (8;9) >>> print(a[1:3]) [6;7) | (8;9)
-