class_docstr: Test that the template defines the correct decomposition.
class_docstr_tok: ["Test","that","the","template","defines","the","correct","decomposition","."]
docstr: Test the correctness of the BasisRotation template including the gate count
  and their order, the wires the operation acts on and the correct use of parameters
  in the circuit.
docstr_tok: ["Test","the","correctness","of","the","BasisRotation","template","including","the","gate","count","and","their","order",",","the","wires","the","operation","acts","on","and","the","correct","use","of","parameters","in","the","circuit","."]
code: def test_basis_rotation_operations(
      self, num_wires, unitary_matrix, givens, diags
  ):
      """Test the correctness of the BasisRotation template including the gate count
      and their order, the wires the operation acts on and the correct use of parameters
      in the circuit."""
  
      gate_ops, gate_angles, gate_wires = [], [], []
  
      for indices, angle in diags + givens[::-1]:
          g_op = (
              qml.PhaseShift
              if len(indices) == 1
              else qml.SingleExcitation
          )
          gate_ops.append(g_op)
          gate_angles.append(qml.numpy.array(angle))
          gate_wires.append(list(indices))
  
      op = qml.BasisRotation(
          wires=range(num_wires), unitary_matrix=unitary_matrix
      )
      queue = op.expand().operations
  
      assert len(queue) == len(gate_ops)  # number of gates
  
      for idx, op in enumerate(queue):
          assert isinstance(op, gate_ops[idx])  # gate operation
          assert np.allclose(
              op.parameters[0], gate_angles[idx]
          )  # gate parameter
          assert list(op.wires) == gate_wires[idx]
  
file_path: pennylane/tests/templates/test_subroutines/test_basis_rotation.py
imports: import pytest
  import numpy
  import pennylane
label_desc: Use image node_id 1 for calling the TestDecomposition obj's underlying member method code with example usage: obj.test_basis_rotation_operations(num_wires, unitary_matrix, givens, diags) without return types