class_docstr: Tests specific to the ControlledQubitUnitary operation
class_docstr_tok: ["Tests","specific","to","the","ControlledQubitUnitary","operation"]
docstr: Test if ControlledQubitUnitary acts like a Toffoli gate when the input unitary is a
  single-qubit X. This test allows the target wire to be any of the three wires.
docstr_tok: ["Test","if","ControlledQubitUnitary","acts","like","a","Toffoli","gate","when","the","input","unitary","is","a","single-qubit","X",".","This","test","allows","the","target","wire","to","be","any","of","the","three","wires","."]
code: def test_toffoli(self, target_wire):
      """Test if ControlledQubitUnitary acts like a Toffoli gate when the input unitary is a
      single-qubit X. This test allows the target wire to be any of the three wires.
      """
      control_wires = list(range(3))
      del control_wires[target_wire]
  
      # pick some random unitaries (with a fixed seed) to make the circuit less trivial
      U1 = unitary_group.rvs(8, random_state=1)
      U2 = unitary_group.rvs(8, random_state=2)
  
      dev = qml.device("default.qubit", wires=3)
  
      @qml.qnode(dev)
      def f1():
          qml.QubitUnitary(U1, wires=range(3))
          qml.ControlledQubitUnitary(
              X, control_wires=control_wires, wires=target_wire
          )
          qml.QubitUnitary(U2, wires=range(3))
          return qml.state()
  
      @qml.qnode(dev)
      def f2():
          qml.QubitUnitary(U1, wires=range(3))
          qml.Toffoli(wires=control_wires + [target_wire])
          qml.QubitUnitary(U2, wires=range(3))
          return qml.state()
  
      state_1 = f1()
      state_2 = f2()
  
      assert np.allclose(state_1, state_2)
  
imports: import copy
  import numpy
  import pytest
  from scipy.linalg import fractional_matrix_power
  from scipy.sparse import csr_matrix
  from scipy.stats import unitary_group
  from gate_data import CY, CZ
  import pennylane
  from pennylane.wires import Wires
  from pennylane.operation import AnyWires
  from pennylane.ops.qubit.matrix_ops import QubitUnitary
label_desc: Use image node_id 6 for calling the TestControlledQubitUnitary obj's underlying member method code with example usage: obj.test_toffoli(target_wire) and returns: qml, qml