class_docstr: Pattern matching circuit optimization tests.
class_docstr_tok: ["Pattern","matching","circuit","optimization","tests","."]
docstr: Test pattern matching algorithm for circuit optimization with no match and therefore no optimization.
docstr_tok: ["Test","pattern","matching","algorithm","for","circuit","optimization","with","no","match","and","therefore","no","optimization","."]
code: def test_no_match_not_optimized(self):
      """Test pattern matching algorithm for circuit optimization with no match and therefore no optimization."""
  
      def circuit():
          qml.Toffoli(wires=[3, 4, 0])
          qml.CNOT(wires=[1, 4])
          qml.CNOT(wires=[2, 1])
          qml.Hadamard(wires=3)
          qml.PauliZ(wires=1)
          qml.CNOT(wires=[2, 3])
          qml.Toffoli(wires=[2, 3, 0])
          qml.CNOT(wires=[1, 4])
          return qml.expval(qml.PauliX(wires=0))
  
      with qml.queuing.AnnotatedQueue() as q_template:
          qml.PauliX(wires=0)
          qml.PauliX(wires=0)
  
      template = qml.tape.QuantumScript.from_queue(q_template)
      dev = qml.device("default.qubit", wires=5)
  
      qnode = qml.QNode(circuit, dev)
      qnode()
  
      optimized_qfunc = pattern_matching_optimization(
          circuit, pattern_tapes=[template]
      )
      optimized_qnode = qml.QNode(optimized_qfunc, dev)
      optimized_qnode()
  
      cnots_qnode = qml.specs(qnode)()["resources"].gate_types["CNOT"]
      cnots_optimized_qnode = qml.specs(optimized_qnode)()[
          "resources"
      ].gate_types["CNOT"]
  
      assert len(qnode.qtape.operations) == 8
      assert cnots_qnode == 4
  
      assert len(optimized_qnode.qtape.operations) == 8
      assert cnots_optimized_qnode == 4
  
      assert np.allclose(
          qml.matrix(optimized_qnode)(), qml.matrix(qnode)()
      )
  
imports: import pytest
  import pennylane
  import pennylane.numpy
  from pennylane.transforms.commutation_dag import commutation_dag
  from pennylane.transforms.optimization.pattern_matching import pattern_matching, pattern_matching_optimization, ForwardMatch, BackwardMatch, _update_qubits
label_desc: Use image node_id 4 for calling the TestPatternMatchingOptimization obj's underlying member method code with example usage: obj.test_no_match_not_optimized() and returns: qml