def transition_indexes(np, nalpha, indexes):
    """
    Returns the list of the indices in the bigdft convention that correspond
    to the couple iorb-ialpha with given spin.

    Args:
        np (tuple): (norbu,norbd) occupied orbitals: when of length 1 assumed
          spin averaged
        nalpha (tuple): (norbu, norbd)virtual orbitals: when of length 1
          assumed spin averaged
        indexes (list): list of tuples of (iorb,ialpha,ispin) desired indices
          in python convention (start from 0)
    """
    nspin = len(np)
    inds = []
    for iorb, ialpha, ispin in indexes:
        jspin = ispin if nspin == 2 else 0
        ind = ialpha+iorb*nalpha[jspin]  # local index of the spin subspace
        if ispin == 1:
            ind += np[0]*nalpha[0]  # spin 2 comes after spin one
        inds.append(ind)
    return inds