class_docstr: Test the private helpers for preprocessing.
class_docstr_tok: ["Test","the","private","helpers","for","preprocessing","."]
docstr: Test that _operator_decomposition_gen handles a decomposition that requires different depths of decomposition.
docstr_tok: ["Test","that","_operator_decomposition_gen","handles","a","decomposition","that","requires","different","depths","of","decomposition","."]
code: def test_operator_decomposition_gen_decomposed_operator_ragged_nesting(
      self,
  ):
      """Test that _operator_decomposition_gen handles a decomposition that requires different depths of decomposition."""
  
      def stopping_condition(op):
          return op.has_matrix
  
      class RaggedDecompositionOp(Operation):
          """class with a ragged decomposition."""
  
          num_wires = 1
  
          def decomposition(self):
              return [
                  NoMatOp(self.wires),
                  qml.S(self.wires),
                  qml.adjoint(NoMatOp(self.wires)),
              ]
  
      op = RaggedDecompositionOp("a")
      final_decomp = list(
          _operator_decomposition_gen(
              op, stopping_condition, self.decomposer
          )
      )
      assert len(final_decomp) == 5
      assert qml.equal(final_decomp[0], qml.PauliX("a"))
      assert qml.equal(final_decomp[1], qml.PauliY("a"))
      assert qml.equal(final_decomp[2], qml.S("a"))
      assert qml.equal(final_decomp[3], qml.adjoint(qml.PauliY("a")))
      assert qml.equal(final_decomp[4], qml.adjoint(qml.PauliX("a")))
  
imports: import pytest
  import pennylane
  from pennylane.operation import Operation
  from pennylane.tape import QuantumScript
  from pennylane import DeviceError
  from pennylane.devices.preprocess import no_sampling, validate_device_wires, validate_multiprocessing_workers, validate_adjoint_trainable_params, _operator_decomposition_gen, decompose, validate_observables, validate_measurements
label_desc: Use image node_id 4 for calling the TestPrivateHelpers obj's underlying member method code with example usage: obj.test_operator_decomposition_gen_decomposed_operator_ragged_nesting() and returns: op, list