def _filter_pairs(starts, stops, coords, indices):
    '\n    Converts all the pairs into a single integer mask, additionally filtering\n    by the indices.\n\n    Parameters\n    ----------\n    starts, stops : list[int]\n        The starts and stops to convert into an array.\n    coords : np.ndarray\n        The coordinates to filter by.\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 : list\n        The output integer mask.\n\n    Examples\n    --------\n    >>> import numpy as np\n    >>> starts = [2]\n    >>> stops = [7]\n    >>> coords = np.array([[0, 1, 2, 3, 4, 5, 6, 7]])\n    >>> indices = np.array([[2, 8, 2]]) # Start, stop, step pairs\n    >>> _filter_pairs(starts, stops, coords, indices)\n    [2, 4, 6]\n    '
    mask = []
    for i in range(len(starts)):
        for j in range(starts[i], stops[i]):
            match = True
            for k in range(len(indices)):
                idx = indices[k]
                elem = coords[(k, j)]
                match &= ((((elem - idx[0]) % idx[2]) == 0) and (((idx[2] > 0) and (idx[0] <= elem < idx[1])) or ((idx[2] < 0) and (idx[0] >= elem > idx[1]))))
            if match:
                mask.append(j)
    return mask
Converts all the pairs into a single integer mask, additionally filtering
by the indices.

Parameters
----------
starts, stops : list[int]
    The starts and stops to convert into an array.
coords : np.ndarray
    The coordinates to filter by.
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 : list
    The output integer mask.

Examples
--------
>>> import numpy as np
>>> starts = [2]
>>> stops = [7]
>>> coords = np.array([[0, 1, 2, 3, 4, 5, 6, 7]])
>>> indices = np.array([[2, 8, 2]]) # Start, stop, step pairs
>>> _filter_pairs(starts, stops, coords, indices)
[2, 4, 6]
def _filter_pairs(starts, stops, coords, indices):
    '\n    Converts all the pairs into a single integer mask, additionally filtering\n    by the indices.\n\n    Parameters\n    ----------\n    starts, stops : list[int]\n        The starts and stops to convert into an array.\n    coords : np.ndarray\n        The coordinates to filter by.\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 : list\n        The output integer mask.\n\n    Examples\n    --------\n    >>> import numpy as np\n    >>> starts = [2]\n    >>> stops = [7]\n    >>> coords = np.array([[0, 1, 2, 3, 4, 5, 6, 7]])\n    >>> indices = np.array([[2, 8, 2]]) # Start, stop, step pairs\n    >>> _filter_pairs(starts, stops, coords, indices)\n    [2, 4, 6]\n    '
    mask = []
    for i in range(len(starts)):
        for j in range(starts[i], stops[i]):
            match = True
            for k in range(len(indices)):
                idx = indices[k]
                elem = coords[(k, j)]
                match &= ((((elem - idx[0]) % idx[2]) == 0) and (((idx[2] > 0) and (idx[0] <= elem < idx[1])) or ((idx[2] < 0) and (idx[0] >= elem > idx[1]))))
            if match:
                mask.append(j)
    return mask