|
|
@@ -60,11 +60,19 @@ cdef class Interval: |
|
|
|
return ("[" + timestamp_to_string(self.start) + |
|
|
|
" -> " + timestamp_to_string(self.end) + ")") |
|
|
|
|
|
|
|
def __cmp__(self, Interval other): |
|
|
|
"""Compare two intervals. If non-equal, order by start then end""" |
|
|
|
def cmp(a, b): |
|
|
|
return (a > b) - (a < b) |
|
|
|
return cmp(self.start, other.start) or cmp(self.end, other.end) |
|
|
|
# Compare two intervals. If non-equal, order by start then end |
|
|
|
def __lt__(self, Interval other): |
|
|
|
return (self.start, self.end) < (other.start, other.end) |
|
|
|
def __gt__(self, Interval other): |
|
|
|
return (self.start, self.end) > (other.start, other.end) |
|
|
|
def __le__(self, Interval other): |
|
|
|
return (self.start, self.end) <= (other.start, other.end) |
|
|
|
def __le__(self, Interval other): |
|
|
|
return (self.start, self.end) >= (other.start, other.end) |
|
|
|
def __eq__(self, Interval other): |
|
|
|
return (self.start, self.end) == (other.start, other.end) |
|
|
|
def __ne__(self, Interval other): |
|
|
|
return (self.start, self.end) != (other.start, other.end) |
|
|
|
|
|
|
|
cpdef intersects(self, Interval other): |
|
|
|
"""Return True if two Interval objects intersect""" |
|
|
|