def _join_adjacent_pairs(starts_old, stops_old):
    '\n    Joins adjacent pairs into one. For example, 2-5 and 5-7\n    will reduce to 2-7 (a single pair). This may help in\n    returning a slice in the end which could be faster.\n\n    Parameters\n    ----------\n    starts_old, stops_old : list[int]\n        The input starts and stops\n\n    Returns\n    -------\n    starts, stops : list[int]\n        The reduced starts and stops.\n\n    Examples\n    --------\n    >>> starts = [2, 5]\n    >>> stops = [5, 7]\n    >>> _join_adjacent_pairs(starts, stops)\n    ([2], [7])\n    '
    if (len(starts_old) <= 1):
        return (starts_old, stops_old)
    starts = [starts_old[0]]
    stops = []
    for i in range(1, len(starts_old)):
        if (starts_old[i] != stops_old[(i - 1)]):
            starts.append(starts_old[i])
            stops.append(stops_old[(i - 1)])
    stops.append(stops_old[(- 1)])
    return (starts, stops)
Joins adjacent pairs into one. For example, 2-5 and 5-7
will reduce to 2-7 (a single pair). This may help in
returning a slice in the end which could be faster.

Parameters
----------
starts_old, stops_old : list[int]
    The input starts and stops

Returns
-------
starts, stops : list[int]
    The reduced starts and stops.

Examples
--------
>>> starts = [2, 5]
>>> stops = [5, 7]
>>> _join_adjacent_pairs(starts, stops)
([2], [7])
def _join_adjacent_pairs(starts_old, stops_old):
    '\n    Joins adjacent pairs into one. For example, 2-5 and 5-7\n    will reduce to 2-7 (a single pair). This may help in\n    returning a slice in the end which could be faster.\n\n    Parameters\n    ----------\n    starts_old, stops_old : list[int]\n        The input starts and stops\n\n    Returns\n    -------\n    starts, stops : list[int]\n        The reduced starts and stops.\n\n    Examples\n    --------\n    >>> starts = [2, 5]\n    >>> stops = [5, 7]\n    >>> _join_adjacent_pairs(starts, stops)\n    ([2], [7])\n    '
    if (len(starts_old) <= 1):
        return (starts_old, stops_old)
    starts = [starts_old[0]]
    stops = []
    for i in range(1, len(starts_old)):
        if (starts_old[i] != stops_old[(i - 1)]):
            starts.append(starts_old[i])
            stops.append(stops_old[(i - 1)])
    stops.append(stops_old[(- 1)])
    return (starts, stops)