# Path: tde/data/interval.py
# def interval_cmp(i1, i2):
#     """Interval comparison function.
# 
#     Compares two intervals as temporal objects on a timeline Interval i1 == i2
#     iff i1.start == i2.start and i1.end == i2.end. If i1 overlaps with i2, the
#     interval with the earliest start is considered the lesser. If i1 does not
#     overlap with i2, the interval with the earliest end is the lesser.
# 
#     The function returns -1 if i1 < i2, 0 if i1 == i2 and 1 if i1 > i2.
# 
#     Parameters
#     ----------
#     i1, i2 : Interval
# 
#     Returns
#     -------
#     int
#         Comparison result.
# 
#     Examples
#     --------
#     >>> i1 = Interval(0, 1)
#     >>> i2 = Interval(2, 3)
#     >>> interval_cmp(i1, i2)
#     -1
#     >>> i2 = Interval(0.5, 1)
#     >>> interval_cmp(i1, i2)
#     0
#     >>> i2 = Interval(0.99, 3)
#     >>> interval_cmp(i1, i2)
#     -1
#     >>> i1 = Interval(4, 5)
#     >>> interval_cmp(i1, i2)
#     1
# 
#     """
#     if i1.overlaps_with(i2):
#         return 0
#     overlap = i1.overlap(i2)
#     if overlap > 0.:
#         if i1.start < i2.start:
#             return -1
#         else:
#             return 1
#     else:
#         if i1.end <= i2.start:  # i1 to the left of i2
#             return -1
#         else:  # i1 to the right of i2
#             return 1


import collections
from tde.data.interval import interval_cmp
                                       ['name', 'interval', 'mark'])
FragmentToken.__repr__ = \
    lambda self: '%s(%r, %r, %r)' % (self.__class__.__name__,
                                     self.name, self.interval,
                                     self.mark)

def token_cmp(token1, token2):
    """Comparison function for FragmentToken objects.

    Compares tokens on their interval. Returns -1 if `token1` < `token2`,
    0 if `token1` == `token2` (that is, they overlap) and
    1 if `token1` > `token2`.

    Parameters
    ----------
    token1, token2 : FragmentToken

    Returns
    -------
    int
        Comparison result.

    Raises
    ------
    ValueError
        If the names of the FragmentTokens don't match.
    """
    if token1.name != token2.name:
        raise ValueError('fragments with different `name` values cannot be '
                         'compared')

# Path: tde/data/interval.py
# def interval_cmp(i1, i2):
#     """Interval comparison function.
# 
#     Compares two intervals as temporal objects on a timeline Interval i1 == i2
#     iff i1.start == i2.start and i1.end == i2.end. If i1 overlaps with i2, the
#     interval with the earliest start is considered the lesser. If i1 does not
#     overlap with i2, the interval with the earliest end is the lesser.
# 
#     The function returns -1 if i1 < i2, 0 if i1 == i2 and 1 if i1 > i2.
# 
#     Parameters
#     ----------
#     i1, i2 : Interval
# 
#     Returns
#     -------
#     int
#         Comparison result.
# 
#     Examples
#     --------
#     >>> i1 = Interval(0, 1)
#     >>> i2 = Interval(2, 3)
#     >>> interval_cmp(i1, i2)
#     -1
#     >>> i2 = Interval(0.5, 1)
#     >>> interval_cmp(i1, i2)
#     0
#     >>> i2 = Interval(0.99, 3)
#     >>> interval_cmp(i1, i2)
#     -1
#     >>> i1 = Interval(4, 5)
#     >>> interval_cmp(i1, i2)
#     1
# 
#     """
#     if i1.overlaps_with(i2):
#         return 0
#     overlap = i1.overlap(i2)
#     if overlap > 0.:
#         if i1.start < i2.start:
#             return -1
#         else:
#             return 1
#     else:
#         if i1.end <= i2.start:  # i1 to the left of i2
#             return -1
#         else:  # i1 to the right of i2
#             return 1


# Path: tde/data/fragment.py
import collections
from tde.data.interval import interval_cmp

                                       ['name', 'interval', 'mark'])
FragmentToken.__repr__ = \
    lambda self: '%s(%r, %r, %r)' % (self.__class__.__name__,
                                     self.name, self.interval,
                                     self.mark)

def token_cmp(token1, token2):
    """Comparison function for FragmentToken objects.

    Compares tokens on their interval. Returns -1 if `token1` < `token2`,
    0 if `token1` == `token2` (that is, they overlap) and
    1 if `token1` > `token2`.

    Parameters
    ----------
    token1, token2 : FragmentToken

    Returns
    -------
    int
        Comparison result.

    Raises
    ------
    ValueError
        If the names of the FragmentTokens don't match.
    """
    if token1.name != token2.name:
        raise ValueError('fragments with different `name` values cannot be '
                         'compared')

    return interval_cmp(token1.interval, token2.interval)