def in_library_len(ind, dist, lib_len):
    """Returns the filtered indices and distances that are in that specific
    library length. This allows the distances to only be calculated once.

    This was created in an attempt to speed up the algorithm. It turns out the
    naive implementation was faster.

    Parameters
    ----------
    ind : 2d array
        Indices to be filtered.
    dist : 2d array
        Distances to be filtered.
    lib_len : int
        What indices to keep.

    Returns
    -------
    filt_ind : 2d array
        Filtered indices.
    filt_dist : 2d array
        Filtered distances.

    """
    mask = ind < lib_len
    filt_ind = ind[mask].reshape(-1, lib_len)
    filt_dist = dist[mask].reshape(-1, lib_len)
    return filt_ind, filt_dist
