Ejemplo n.º 1
0
def test_validate_circuit_and_shots_100_noncommuting():
    validate_circuit_and_shots(
        Circuit().h(0).expectation(observables.X() @ observables.Y(),
                                   [0, 1]).expectation(
                                       observables.Y() @ observables.X(),
                                       [0, 1]),
        100,
    )
def test_translate_result_type_hamiltonian_expectation():
    """Tests that a Hamiltonian is translated correctly"""
    obs = qml.Hamiltonian((2, 3), (qml.PauliX(wires=0), qml.PauliY(wires=1)))
    obs.return_type = ObservableReturnTypes.Expectation
    braket_result_type_calculated = translate_result_type(obs, [0], frozenset())
    braket_result_type = (Expectation(observables.X(), [0]), Expectation(observables.Y(), [1]))
    assert braket_result_type == braket_result_type_calculated
Ejemplo n.º 3
0
def _(y: qml.PauliY):
    return observables.Y()