class_docstr: Test that the template defines the correct decomposition.
class_docstr_tok: ["Test","that","the","template","defines","the","correct","decomposition","."]
docstr: Test that the BasisRotation template works correctly asserting the prepared state.
docstr_tok: ["Test","that","the","BasisRotation","template","works","correctly","asserting","the","prepared","state","."]
code: def test_basis_rotation_unitary(
      self, unitary_matrix, eigen_values, exp_state
  ):
      """Test that the BasisRotation template works correctly asserting the prepared state."""
  
      wires = range(len(unitary_matrix))
      dev = qml.device("default.qubit", wires=wires)
  
      @qml.qnode(dev)
      def circuit():
          qml.PauliX(0)
          qml.PauliX(1)
          qml.adjoint(
              qml.BasisRotation(
                  wires=wires, unitary_matrix=unitary_matrix
              )
          )
          for idx, eigenval in enumerate(eigen_values):
              qml.RZ(-eigenval, wires=[idx])
          qml.BasisRotation(wires=wires, unitary_matrix=unitary_matrix)
          return qml.state()
  
      assert np.allclose(
          [qml.math.fidelity_statevector(circuit(), exp_state)],
          [1.0],
          atol=1e-6,
      )
  
file_path: pennylane/tests/templates/test_subroutines/test_basis_rotation.py
imports: import pytest
  import numpy
  import pennylane
label_desc: Use image node_id 3 for calling the TestDecomposition obj's underlying member method code with example usage: obj.test_basis_rotation_unitary(unitary_matrix, eigen_values, exp_state) and returns: qml