class_docstr: Unit tests for helper functions in qml.devices.qubit.preprocess
class_docstr_tok: ["Unit","tests","for","helper","functions","in","qml.devices.qubit.preprocess"]
docstr: Test that a device error is raised if decomposition enters an infinite loop.
docstr_tok: ["Test","that","a","device","error","is","raised","if","decomposition","enters","an","infinite","loop","."]
code: def test_infinite_decomposition_loop(self):
      """Test that a device error is raised if decomposition enters an infinite loop."""
  
      class InfiniteOp(qml.operation.Operation):
          """An op with an infinite decomposition."""
  
          num_wires = 1
  
          def decomposition(self):
              return [InfiniteOp(*self.parameters, self.wires)]
  
      qs = qml.tape.QuantumScript([InfiniteOp(1.23, 0)])
      with pytest.raises(
          DeviceError,
          match=r"Reached recursion limit trying to decompose",
      ):
          decompose(qs, lambda obj: obj.has_matrix)
  
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 3 for calling the TestDecomposeValidation obj's underlying member method code with example usage: obj.test_infinite_decomposition_loop() and returns: list