def test_paulix_expectation(self, device, shots, tol):
    'Test that PauliX expectation value is correct'
    theta = 0.432
    phi = 0.123
    dev = device(2)
    O = qml.PauliX
    with mimic_execution_for_expval(dev):
        dev.apply([qml.RY(theta, wires=[0]), qml.RY(phi, wires=[1]), qml.CNOT(wires=[0, 1])], rotations=(O(wires=[0], do_queue=False).diagonalizing_gates() + O(wires=[1], do_queue=False).diagonalizing_gates()))
    dev._obs_queue = [O(wires=[0], do_queue=False), O(wires=[1], do_queue=False)]
    res = np.array([dev.expval(O(wires=[0], do_queue=False)), dev.expval(O(wires=[1], do_queue=False))])
    assert np.allclose(res, np.array([(np.sin(theta) * np.sin(phi)), np.sin(phi)]), **tol)
Test that PauliX expectation value is correct
def test_paulix_expectation(self, device, shots, tol):
    
    theta = 0.432
    phi = 0.123
    dev = device(2)
    O = qml.PauliX
    with mimic_execution_for_expval(dev):
        dev.apply([qml.RY(theta, wires=[0]), qml.RY(phi, wires=[1]), qml.CNOT(wires=[0, 1])], rotations=(O(wires=[0], do_queue=False).diagonalizing_gates() + O(wires=[1], do_queue=False).diagonalizing_gates()))
    dev._obs_queue = [O(wires=[0], do_queue=False), O(wires=[1], do_queue=False)]
    res = np.array([dev.expval(O(wires=[0], do_queue=False)), dev.expval(O(wires=[1], do_queue=False))])
    assert np.allclose(res, np.array([(np.sin(theta) * np.sin(phi)), np.sin(phi)]), **tol)