class_docstr: Integration tests for the ParametrizedEvolution class.
class_docstr_tok: ["Integration","tests","for","the","ParametrizedEvolution","class","."]
docstr: Test that the evolution of two parametrized hamiltonians that commute with each other
  is equal to evolve the two hamiltonians simultaneously. This test uses 8 wires for the device
  to test the case where 2 * n < N (the matrix is evolved instead of the state).
docstr_tok: ["Test","that","the","evolution","of","two","parametrized","hamiltonians","that","commute","with","each","other","is","equal","to","evolve","the","two","hamiltonians","simultaneously",".","This","test","uses","8","wires","for","the","device","to","test","the","case","where","2","*","n","<","N","(","the","matrix","is","evolved","instead","of","the","state",")","."]
code: def test_two_commuting_parametrized_hamiltonians(self, device_class):
      """Test that the evolution of two parametrized hamiltonians that commute with each other
      is equal to evolve the two hamiltonians simultaneously. This test uses 8 wires for the device
      to test the case where 2 * n < N (the matrix is evolved instead of the state).
      """
      import jax
      import jax.numpy as jnp
  
      def f1(p, t):
          return p * t
  
      def f2(p, t):
          return jnp.sin(t) * (p - 1)
  
      coeffs = [1, f1, f2]
      ops = [qml.PauliX(0), qml.PauliY(1), qml.PauliX(2)]
      H1_ = qml.dot(coeffs, ops)
  
      def f3(p, t):
          return jnp.cos(t) * (p + 1)
  
      coeffs = [7, f3]
      ops = [qml.PauliX(0), qml.PauliX(2)]
      H2_ = qml.dot(coeffs, ops)
  
      dev = device_class(wires=8)
  
      @jax.jit
      @qml.qnode(dev, interface="jax")
      def circuit1(params):
          qml.evolve(H1_)(params[0], t=2)
          qml.evolve(H2_)(params[1], t=2)
          return qml.expval(
              qml.PauliZ(0) @ qml.PauliZ(1) @ qml.PauliZ(2)
          )
  
      @jax.jit
      @qml.qnode(dev, interface="jax")
      def circuit2(params):
          qml.evolve(H1_ + H2_)(params, t=2)
          return qml.expval(
              qml.PauliZ(0) @ qml.PauliZ(1) @ qml.PauliZ(2)
          )
  
      params1 = [(1.0, 2.0), (3.0,)]
      params2 = [1.0, 2.0, 3.0]
  
      assert qml.math.allclose(
          circuit1(params1), circuit2(params2), atol=5e-4
      )
      assert qml.math.allclose(
          qml.math.concatenate(jax.grad(circuit1)(params1)),
          jax.grad(circuit2)(params2),
          atol=5e-4,
      )
  
imports: from functools import reduce
  import numpy
  import pytest
  import pennylane
  from pennylane.operation import AnyWires
  from pennylane.ops import QubitUnitary
  from pennylane.pulse import ParametrizedEvolution, ParametrizedHamiltonian
  from pennylane.tape import QuantumTape
  from pennylane.devices import DefaultQubit, DefaultQubitLegacy
label_desc: Use image node_id 5 for calling the TestIntegration obj's underlying member method code with example usage: obj.test_two_commuting_parametrized_hamiltonians(device_class) and returns: unknown, unknown, unknown, qml, qml