class_docstr: Tests for single-qubit gates being pushed through controlled gates.
class_docstr_tok: ["Tests","for","single-qubit","gates","being","pushed","through","controlled","gates","."]
docstr: Test that X-basis gates before controlled-X-type gates on targets get pushed ahead.
docstr_tok: ["Test","that","X-basis","gates","before","controlled-X-type","gates","on","targets","get","pushed","ahead","."]
code: def test_push_x_gates_right(self):
      """Test that X-basis gates before controlled-X-type gates on targets get pushed ahead."""
  
      def qfunc():
          qml.PauliX(wires=2)
          qml.CNOT(wires=[0, 2])
          qml.RX(0.2, wires=2)
          qml.Toffoli(wires=[0, 1, 2])
          qml.SX(wires=1)
          qml.PauliX(wires=1)
          qml.CRX(0.1, wires=[0, 1])
  
      transformed_qfunc = commute_controlled(qfunc)
  
      ops = qml.tape.make_qscript(transformed_qfunc)().operations
  
      names_expected = [
          "CNOT",
          "Toffoli",
          "PauliX",
          "RX",
          "CRX",
          "SX",
          "PauliX",
      ]
      wires_expected = [
          Wires([0, 2]),
          Wires([0, 1, 2]),
          Wires(2),
          Wires(2),
          Wires([0, 1]),
          Wires(1),
          Wires(1),
      ]
      compare_operation_lists(ops, names_expected, wires_expected)
  
imports: import pytest
  from utils import compare_operation_lists, check_matrix_equivalence
  import pennylane
  from pennylane import numpy
  from pennylane.wires import Wires
  from pennylane.transforms.optimization import commute_controlled
label_desc: Use image node_id 4 for calling the TestCommuteControlled obj's underlying member method code with example usage: obj.test_push_x_gates_right() without return types