operations on [x..y[ intervals
-
interval.in_interval(interval, x)[source]
True if x is in interval [a,b] or [b,a] (tuple)
-
interval.intersect(t1, t2)[source]
True if sorted tuples intervals [t1[ [t2[ intersect
-
interval.intersection(t1, t2)[source]
returns intersection between 2 intervals (tuples),
or (None,None) if intervals don’t intersect
-
interval.intersectlen(t1, t2, none=0)[source]
returns len of intersection between 2 intervals (tuples),
or none if intervals don’t intersect
-
class interval.Interval(start, end)[source]
Bases: object
Represents an interval.
Defined as half-open interval [start,end), which includes the start position but not the end.
Start and end do not have to be numeric types.
http://code.activestate.com/recipes/576816-interval/
alternative could be http://pypi.python.org/pypi/
Construct, start must be <= end.
-
__init__(start, end)[source]
Construct, start must be <= end.
-
start
The interval’s start
-
end
The interval’s end
-
__str__()[source]
As string.
-
__repr__()[source]
String representation.
-
__cmp__(other)[source]
Compare.
-
__hash__()[source]
Hash.
-
intersection(other)[source]
Intersection. @return: None if no intersection.
-
hull(other)[source]
@return: Interval containing both self and other.
-
overlap(other)[source]
@return: True iff self intersects other.
-
__contains__(item)[source]
@return: True iff item in self.
-
contains(x)[source]
@return: True iff 0 in self.
-
subset(other)[source]
@return: True iff self is subset of other.
-
proper_subset(other)[source]
@return: True iff self is proper subset of other.
-
empty()[source]
@return: True iff self is empty.
-
singleton()[source]
@return: True iff self.end - self.start == 1.
-
separation(other)[source]
@return: The distance between self and other.
-
__weakref__
list of weak references to the object (if defined)
-
class interval.Intervals(init=[])[source]
Bases: list
a list of intevals kept in ascending order
-
__init__(init=[])[source]
-
extend(iterable)[source]
-
append(item)[source]
-
__call__(x)[source]
returns list of intervals containing x
-
__weakref__
list of weak references to the object (if defined)
-
class interval.TestCase(methodName='runTest')[source]
Bases: unittest.case.TestCase
Create an instance of the class that will use the named test
method when executed. Raises a ValueError if the instance does
not have a method with the specified name.
-
setUp()[source]
-
runTest()[source]