def _one_q_pauli_prep(label, index, qubit):
    """Prepare the index-th eigenstate of the pauli operator given by label."""
    if index not in [0, 1]:
        raise ValueError(f'Bad Pauli index: {index}')

    if label == 'X':
        if index == 0:
            return Program(RY(pi / 2, qubit))
        else:
            return Program(RY(-pi / 2, qubit))

    elif label == 'Y':
        if index == 0:
            return Program(RX(-pi / 2, qubit))
        else:
            return Program(RX(pi / 2, qubit))

    elif label == 'Z':
        if index == 0:
            return Program()
        else:
            return Program(RX(pi, qubit))

    raise ValueError(f'Bad Pauli label: {label}')
def _one_q_pauli_prep ( label , index , qubit ) : if index not in [ 0 , 1 ] : raise ValueError ( f'Bad Pauli index: {index}' ) if label == 'X' : if index == 0 : return Program ( RY ( pi / 2 , qubit ) ) else : return Program ( RY ( - pi / 2 , qubit ) ) elif label == 'Y' : if index == 0 : return Program ( RX ( - pi / 2 , qubit ) ) else : return Program ( RX ( pi / 2 , qubit ) ) elif label == 'Z' : if index == 0 : return Program ( ) else : return Program ( RX ( pi , qubit ) ) raise ValueError ( f'Bad Pauli label: {label}' )
Prepare the index-th eigenstate of the pauli operator given by label.