class_docstr: Test that the QDrift template integrates well with the rest of PennyLane
class_docstr_tok: ["Test","that","the","QDrift","template","integrates","well","with","the","rest","of","PennyLane"]
docstr: Test that the circuit executes as expected
docstr_tok: ["Test","that","the","circuit","executes","as","expected"]
code: def test_execution(
      self, coeffs, ops, time, n, seed
  ):  # pylint: disable=too-many-arguments
      """Test that the circuit executes as expected"""
      hamiltonian = qml.dot(coeffs, ops)
      wires = hamiltonian.wires
      dev = qml.device("default.qubit", wires=wires)
  
      @qml.qnode(dev)
      def circ():
          qml.QDrift(hamiltonian, time, n=n, seed=seed)
          return qml.state()
  
      expected_decomp = _sample_decomposition(
          coeffs, ops, time, n=n, seed=seed
      )
  
      initial_state = qnp.zeros(2 ** (len(wires)))
      initial_state[0] = 1
  
      expected_state = (
          reduce(
              lambda x, y: x @ y,
              [
                  qml.matrix(op, wire_order=wires)
                  for op in expected_decomp
              ],
          )
          @ initial_state
      )
      state = circ()
  
      assert allclose(expected_state, state)
  
imports: import copy
  from functools import reduce
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.math import allclose, isclose
  from pennylane.templates.subroutines.qdrift import _sample_decomposition
label_desc: Use image node_id 1 for calling the TestIntegration obj's underlying member method code with example usage: obj.test_execution(coeffs, ops, time, n, seed) and returns: qml