def compute_mask(coords, indices):
    '\n    Gets the mask for the coords given the indices in slice format.\n\n    Works with either start-stop ranges of matching indices into coords\n    called "pairs" (start-stop pairs) or filters the mask directly, based\n    on which is faster.\n\n    Exploits the structure in sorted coords, which is that for a constant\n    value of coords[i - 1], coords[i - 2] and so on, coords[i] is sorted.\n    Concretely, ``coords[i, coords[i - 1] == v1 & coords[i - 2] = v2, ...]``\n    is always sorted. It uses this sortedness to find sub-pairs for each\n    dimension given the previous, and so on. This is efficient for small\n    slices or ints, but not for large ones.\n\n    After it detects that working with pairs is rather inefficient (or after\n    going through each possible index), it constructs a filtered mask from the\n    start-stop pairs.\n\n    Parameters\n    ----------\n    coords : np.ndarray\n        The coordinates of the array.\n    indices : np.ndarray\n        The indices in the form of slices such that indices[:, 0] are starts,\n        indices[:, 1] are stops and indices[:, 2] are steps.\n\n    Returns\n    -------\n    mask : np.ndarray\n        The starts and stops in the mask.\n    is_slice : bool\n        Whether or not the array represents a continuous slice.\n\n    Examples\n    --------\n    Let\'s create some mock coords and indices\n\n    >>> import numpy as np\n    >>> coords = np.array([[0, 0, 1, 1, 2, 2]])\n    >>> indices = np.array([[0, 3, 2]])  # Equivalent to slice(0, 3, 2)\n\n    Now let\'s get the mask. Notice that the indices of ``0`` and ``2`` are matched.\n\n    >>> _compute_mask(coords, indices)\n    (array([0, 1, 4, 5]), False)\n\n    Now, let\'s try with a more "continuous" slice. Matches ``0`` and ``1``.\n\n    >>> indices = np.array([[0, 2, 1]])\n    >>> _compute_mask(coords, indices)\n    (array([0, 4]), True)\n\n    This is equivalent to mask being ``slice(0, 4, 1)``.\n    '
    starts = [0]
    stops = [coords.shape[1]]
    n_matches = coords.shape[1]
    i = 0
    while (i < len(indices)):
        n_pairs = len(starts)
        n_current_slices = ((_get_slice_len(indices[i]) * n_pairs) + 2)
        if ((n_current_slices * np.log((n_current_slices / max(n_pairs, 1)))) > (n_matches + n_pairs)):
            break
        (starts, stops, n_matches) = _get_mask_pairs(starts, stops, coords[i], indices[i])
        i += 1
    (starts, stops) = _join_adjacent_pairs(starts, stops)
    if ((i == len(indices)) and (len(starts) == 1)):
        return (np.array([starts[0], stops[0]]), True)
    mask = _filter_pairs(starts, stops, coords[i:], indices[i:])
    return (np.array(mask, dtype=np.intp), False)
Gets the mask for the coords given the indices in slice format.

Works with either start-stop ranges of matching indices into coords
called "pairs" (start-stop pairs) or filters the mask directly, based
on which is faster.

Exploits the structure in sorted coords, which is that for a constant
value of coords[i - 1], coords[i - 2] and so on, coords[i] is sorted.
Concretely, ``coords[i, coords[i - 1] == v1 & coords[i - 2] = v2, ...]``
is always sorted. It uses this sortedness to find sub-pairs for each
dimension given the previous, and so on. This is efficient for small
slices or ints, but not for large ones.

After it detects that working with pairs is rather inefficient (or after
going through each possible index), it constructs a filtered mask from the
start-stop pairs.

Parameters
----------
coords : np.ndarray
    The coordinates of the array.
indices : np.ndarray
    The indices in the form of slices such that indices[:, 0] are starts,
    indices[:, 1] are stops and indices[:, 2] are steps.

Returns
-------
mask : np.ndarray
    The starts and stops in the mask.
is_slice : bool
    Whether or not the array represents a continuous slice.

Examples
--------
Let's create some mock coords and indices

>>> import numpy as np
>>> coords = np.array([[0, 0, 1, 1, 2, 2]])
>>> indices = np.array([[0, 3, 2]])  # Equivalent to slice(0, 3, 2)

Now let's get the mask. Notice that the indices of ``0`` and ``2`` are matched.

>>> _compute_mask(coords, indices)
(array([0, 1, 4, 5]), False)

Now, let's try with a more "continuous" slice. Matches ``0`` and ``1``.

>>> indices = np.array([[0, 2, 1]])
>>> _compute_mask(coords, indices)
(array([0, 4]), True)

This is equivalent to mask being ``slice(0, 4, 1)``.
def compute_mask(coords, indices):
    '\n    Gets the mask for the coords given the indices in slice format.\n\n    Works with either start-stop ranges of matching indices into coords\n    called "pairs" (start-stop pairs) or filters the mask directly, based\n    on which is faster.\n\n    Exploits the structure in sorted coords, which is that for a constant\n    value of coords[i - 1], coords[i - 2] and so on, coords[i] is sorted.\n    Concretely, ``coords[i, coords[i - 1] == v1 & coords[i - 2] = v2, ...]``\n    is always sorted. It uses this sortedness to find sub-pairs for each\n    dimension given the previous, and so on. This is efficient for small\n    slices or ints, but not for large ones.\n\n    After it detects that working with pairs is rather inefficient (or after\n    going through each possible index), it constructs a filtered mask from the\n    start-stop pairs.\n\n    Parameters\n    ----------\n    coords : np.ndarray\n        The coordinates of the array.\n    indices : np.ndarray\n        The indices in the form of slices such that indices[:, 0] are starts,\n        indices[:, 1] are stops and indices[:, 2] are steps.\n\n    Returns\n    -------\n    mask : np.ndarray\n        The starts and stops in the mask.\n    is_slice : bool\n        Whether or not the array represents a continuous slice.\n\n    Examples\n    --------\n    Let\'s create some mock coords and indices\n\n    >>> import numpy as np\n    >>> coords = np.array([[0, 0, 1, 1, 2, 2]])\n    >>> indices = np.array([[0, 3, 2]])  # Equivalent to slice(0, 3, 2)\n\n    Now let\'s get the mask. Notice that the indices of ``0`` and ``2`` are matched.\n\n    >>> _compute_mask(coords, indices)\n    (array([0, 1, 4, 5]), False)\n\n    Now, let\'s try with a more "continuous" slice. Matches ``0`` and ``1``.\n\n    >>> indices = np.array([[0, 2, 1]])\n    >>> _compute_mask(coords, indices)\n    (array([0, 4]), True)\n\n    This is equivalent to mask being ``slice(0, 4, 1)``.\n    '
    starts = [0]
    stops = [coords.shape[1]]
    n_matches = coords.shape[1]
    i = 0
    while (i < len(indices)):
        n_pairs = len(starts)
        n_current_slices = ((_get_slice_len(indices[i]) * n_pairs) + 2)
        if ((n_current_slices * np.log((n_current_slices / max(n_pairs, 1)))) > (n_matches + n_pairs)):
            break
        (starts, stops, n_matches) = _get_mask_pairs(starts, stops, coords[i], indices[i])
        i += 1
    (starts, stops) = _join_adjacent_pairs(starts, stops)
    if ((i == len(indices)) and (len(starts) == 1)):
        return (np.array([starts[0], stops[0]]), True)
    mask = _filter_pairs(starts, stops, coords[i:], indices[i:])
    return (np.array(mask, dtype=np.intp), False)