def _correlations_to_indices(correlations, basis):
    """
    Helper function to select correct indices given the local state values in
    basis.n_states.

    Args:
        correlations: list of correlations to be computed
        basis: an instance of a basis class.

    Returns:
        list of correlations in terms of indices
    """
    try:
        l_0 = tuple([list(basis.n_states).index(_l[0]) for _l in correlations])
        l_1 = tuple([list(basis.n_states).index(_l[1]) for _l in correlations])
    except ValueError as ve:
        raise ValueError('correlations value ' + str(ve) +
                         ' is not in basis.n_states')
    return (l_0, l_1)