class_docstr: Test that sequences of any single-qubit rotations are fully fused.
class_docstr_tok: ["Test","that","sequences","of","any","single-qubit","rotations","are","fully","fused","."]
docstr: Test that fusion is correctly skipped for gates explicitly on an
  exclusion list.
docstr_tok: ["Test","that","fusion","is","correctly","skipped","for","gates","explicitly","on","an","exclusion","list","."]
code: def test_single_qubit_fusion_exclude_gates(self):
      """Test that fusion is correctly skipped for gates explicitly on an
      exclusion list."""
  
      def qfunc():
          # Excluded gate at the start
          qml.RZ(0.1, wires=0)
          qml.Hadamard(wires=0)
          qml.PauliX(wires=0)
          qml.RZ(0.1, wires=1)
          qml.CNOT(wires=[0, 1])
          qml.Hadamard(wires=0)
          # Excluded gate after another gate
          qml.RZ(0.1, wires=0)
          qml.PauliX(wires=1)
          qml.PauliZ(wires=1)
          # Excluded gate after multiple others
          qml.RZ(0.2, wires=1)
  
      transformed_qfunc = single_qubit_fusion(
          qfunc, exclude_gates=["RZ"]
      )
      transformed_ops = qml.tape.make_qscript(
          transformed_qfunc
      )().operations
  
      names_expected = [
          "RZ",
          "Rot",
          "RZ",
          "CNOT",
          "Hadamard",
          "RZ",
          "Rot",
          "RZ",
      ]
      wires_expected = (
          [Wires(0)] * 2
          + [Wires(1)]
          + [Wires([0, 1])]
          + [Wires(0)] * 2
          + [Wires(1)] * 2
      )
      compare_operation_lists(
          transformed_ops, names_expected, wires_expected
      )
  
      # Compare matrices
      matrix_expected = qml.matrix(qfunc, [0, 1])()
  
      matrix_obtained = qml.matrix(transformed_qfunc, [0, 1])()
      assert check_matrix_equivalence(matrix_expected, matrix_obtained)
  
imports: import pytest
  from utils import compare_operation_lists, check_matrix_equivalence
  from pennylane import numpy
  import pennylane
  from pennylane.wires import Wires
  from pennylane.transforms.optimization import single_qubit_fusion
label_desc: Use image node_id 6 for calling the TestSingleQubitFusion obj's underlying member method code with example usage: obj.test_single_qubit_fusion_exclude_gates() without return types