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 arbitrary gates after controlled gates on controls *and*
  targets get properly pushed.
docstr_tok: ["Test","that","arbitrary","gates","after","controlled","gates","on","controls","*","and","*","targets","get","properly","pushed","."]
code: def test_push_mixed_with_matrix(self, direction):
      """Test that arbitrary gates after controlled gates on controls *and*
      targets get properly pushed."""
      # pylint:disable=too-many-function-args
  
      def qfunc():
          qml.PauliX(wires=1)
          qml.S(wires=0)
          qml.CZ(wires=[0, 1])
          qml.CNOT(wires=[1, 0])
          qml.PauliY(wires=1)
          qml.CRY(0.5, wires=[1, 0])
          qml.PhaseShift(0.2, wires=0)
          qml.PauliY(wires=1)
          qml.T(wires=0)
          qml.CRZ(-0.3, wires=[0, 1])
          qml.RZ(0.2, wires=0)
          qml.PauliZ(wires=0)
          qml.PauliX(wires=1)
          qml.CRY(0.2, wires=[1, 0])
  
      transformed_qfunc = commute_controlled(qfunc, direction=direction)
  
      original_ops = qml.tape.make_qscript(qfunc)().operations
      transformed_ops = qml.tape.make_qscript(
          transformed_qfunc
      )().operations
  
      assert len(original_ops) == len(transformed_ops)
  
      # Compare matrices
      compute_matrix = qml.matrix(qfunc, [0, 1])
      matrix_expected = compute_matrix()
  
      compute_transformed_matrix = qml.matrix(transformed_qfunc, [0, 1])
      matrix_obtained = compute_transformed_matrix()
  
      assert check_matrix_equivalence(matrix_expected, matrix_obtained)
  
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 12 for calling the TestCommuteControlled obj's underlying member method code with example usage: obj.test_push_mixed_with_matrix(direction) without return types