class_docstr: Test the decomposition of the TrotterProduct class.
class_docstr_tok: ["Test","the","decomposition","of","the","TrotterProduct","class","."]
docstr: Test the decomposition is correct when we set the number of trotter steps
docstr_tok: ["Test","the","decomposition","is","correct","when","we","set","the","number","of","trotter","steps"]
code: def test_compute_decomposition_n_steps(self, num_steps, order):
      """Test the decomposition is correct when we set the number of trotter steps"""
      time = 0.5
      hamiltonian = qml.sum(qml.PauliX(0), qml.PauliZ(0))
  
      if order == 1:
          base_decomp = [
              qml.exp(qml.PauliZ(0), 0.5j / num_steps),
              qml.exp(qml.PauliX(0), 0.5j / num_steps),
          ]
      if order == 2:
          base_decomp = [
              qml.exp(qml.PauliX(0), 0.25j / num_steps),
              qml.exp(qml.PauliZ(0), 0.25j / num_steps),
              qml.exp(qml.PauliZ(0), 0.25j / num_steps),
              qml.exp(qml.PauliX(0), 0.25j / num_steps),
          ]
  
      true_decomp = base_decomp * num_steps
  
      op = qml.TrotterProduct(
          hamiltonian, time, n=num_steps, order=order
      )
      decomp = op.compute_decomposition(
          *op.parameters, **op.hyperparameters
      )
      assert all(
          qml.equal(op1, op2) for op1, op2 in zip(decomp, true_decomp)
      )
  
imports: import copy
  from functools import reduce
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.math import allclose, get_interface
  from pennylane.templates.subroutines.trotter import _recursive_expression, _scalar
label_desc: Use image node_id 2 for calling the TestDecomposition obj's underlying member method code with example usage: obj.test_compute_decomposition_n_steps(num_steps, order) without return types