def test_identity_expectation(self, device, shots, tol):
    'Test that identity expectation value (i.e. the trace) is 1'
    theta = 0.432
    phi = 0.123
    dev = device(2)
    with mimic_execution_for_expval(dev):
        dev.apply([qml.RX(theta, wires=[0]), qml.RX(phi, wires=[1]), qml.CNOT(wires=[0, 1])])
    O = qml.Identity
    name = 'Identity'
    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([1, 1]), **tol)
Test that identity expectation value (i.e. the trace) is 1
def test_identity_expectation(self, device, shots, tol):
    
    theta = 0.432
    phi = 0.123
    dev = device(2)
    with mimic_execution_for_expval(dev):
        dev.apply([qml.RX(theta, wires=[0]), qml.RX(phi, wires=[1]), qml.CNOT(wires=[0, 1])])
    O = qml.Identity
    name = 'Identity'
    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([1, 1]), **tol)