def test_qnode_fails_on_gates_after_measurements(self, qubit_device_2_wires):
    'Gates have to precede measurements'

    @qml.qnode(qubit_device_2_wires, interface='tf')
    def qf(x):
        qml.RX(x, wires=[0])
        ev = qml.expval(qml.PauliZ(1))
        qml.RY(0.5, wires=[0])
        return ev
    with pytest.raises(QuantumFunctionError, match='gates must precede'):
        qf(Variable(0.5))
Gates have to precede measurements
def test_qnode_fails_on_gates_after_measurements(self, qubit_device_2_wires):
    

    @qml.qnode(qubit_device_2_wires, interface='tf')
    def qf(x):
        qml.RX(x, wires=[0])
        ev = qml.expval(qml.PauliZ(1))
        qml.RY(0.5, wires=[0])
        return ev
    with pytest.raises(QuantumFunctionError, match='gates must precede'):
        qf(Variable(0.5))