class_docstr: Unit tests for validate_and_expand_adjoint
class_docstr_tok: ["Unit","tests","for","validate_and_expand_adjoint"]
docstr: Test that an operation supported on the forward pass but not adjoint is decomposed when adjoint is requested.
docstr_tok: ["Test","that","an","operation","supported","on","the","forward","pass","but","not","adjoint","is","decomposed","when","adjoint","is","requested","."]
code: def test_unsupported_op_decomposed(self):
      """Test that an operation supported on the forward pass but not adjoint is decomposed when adjoint is requested."""
  
      qs = qml.tape.QuantumScript(
          [qml.U2(0.1, 0.2, wires=[0])], [qml.expval(qml.PauliZ(2))]
      )
      batch = (qs,)
      program = qml.device("default.qubit").preprocess(
          ExecutionConfig(gradient_method="adjoint")
      )[0]
      res, _ = program(batch)
      res = res[0]
      assert isinstance(res, qml.tape.QuantumScript)
      assert qml.equal(res[0], qml.RZ(0.2, wires=0))
      assert qml.equal(res[1], qml.RY(np.pi / 2, wires=0))
      assert qml.equal(res[2], qml.RZ(-0.2, wires=0))
      assert qml.equal(res[3], qml.PhaseShift(0.2, wires=0))
      assert qml.equal(res[4], qml.PhaseShift(0.1, wires=0))
  
imports: import pytest
  import numpy
  import pennylane
  from pennylane.devices import DefaultQubit, ExecutionConfig
  from pennylane.devices.default_qubit import stopping_condition
label_desc: Use image node_id 3 for calling the TestAdjointDiffTapeValidation obj's underlying member method code with example usage: obj.test_unsupported_op_decomposed() without return types