class_docstr: Unit tests for the ``rydberg_drive`` function
docstr: Test that adding multiple drive terms behaves as expected
docstr_tok: ["Test","that","adding","multiple","drive","terms","behaves","as","expected"]
code: def test_multiple_local_drives(self):
      """Test that adding multiple drive terms behaves as expected"""
  
      # factors (2 * np.pi) to convert between angular and standard frequency
      def fa(p, t):
          return np.sin(p * t) / (2 * np.pi)
  
      def fb(p, t):
          return np.cos(p * t)
  
      H1 = rydberg_drive(
          amplitude=fa, phase=1, detuning=3, wires=[0, 3]
      )
      H2 = rydberg_drive(
          amplitude=1 / (2 * np.pi), phase=3, detuning=fb, wires=[1, 2]
      )
      Hd = H1 + H2
  
      ops_expected = [
          qml.Hamiltonian(
              [
                  -0.5 * (2 * np.pi),
                  -0.5 * (2 * np.pi),
                  0.5 * (2 * np.pi),
                  0.5 * (2 * np.pi),
              ],
              [
                  qml.Identity(0),
                  qml.Identity(3),
                  qml.PauliZ(0),
                  qml.PauliZ(3),
              ],
          ),
          qml.Hamiltonian([0.5, 0.5], [qml.PauliX(1), qml.PauliX(2)]),
          qml.Hamiltonian([-0.5, -0.5], [qml.PauliY(1), qml.PauliY(2)]),
          qml.Hamiltonian([0.5, 0.5], [qml.PauliX(0), qml.PauliX(3)]),
          qml.Hamiltonian([-0.5, -0.5], [qml.PauliY(0), qml.PauliY(3)]),
          qml.Hamiltonian(
              [
                  -0.5 * (2 * np.pi),
                  -0.5 * (2 * np.pi),
                  0.5 * (2 * np.pi),
                  0.5 * (2 * np.pi),
              ],
              [
                  qml.Identity(1),
                  qml.Identity(2),
                  qml.PauliZ(1),
                  qml.PauliZ(2),
              ],
          ),
      ]
      coeffs_expected = [
          3,
          np.cos(3),
          np.sin(3),
          AmplitudeAndPhase(np.cos, fa, 1),
          AmplitudeAndPhase(np.sin, fa, 1),
          fb,
      ]
      H_expected = HardwareHamiltonian(coeffs_expected, ops_expected)
  
      # structure of Hamiltonian is as expected
      assert isinstance(Hd, HardwareHamiltonian)
      assert Hd.wires == Wires([0, 3, 1, 2])
      assert Hd.settings is None
      assert (
          len(Hd.ops) == 6
      )  # 2 terms for amplitude/phase and one detuning for each drive
  
      # coefficients are correct
      # Callable coefficients are shifted to the end of the list.
      assert Hd.coeffs[0:3] == [3, np.cos(3), np.sin(3)]
      assert isinstance(Hd.coeffs[3], AmplitudeAndPhase)
      assert isinstance(Hd.coeffs[4], AmplitudeAndPhase)
      assert Hd.coeffs[5] is fb
  
      # pulses were added correctly
      assert len(Hd.pulses) == 2
      assert Hd.pulses == H1.pulses + H2.pulses
  
      # Hamiltonian is as expected
      actual = Hd([0.5, -0.5], t=5).simplify()
      expected = H_expected([0.5, -0.5], t=5).simplify()
      assert qml.equal(actual, expected)
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane.pulse import rydberg_interaction, rydberg_drive
  from pennylane.pulse.hardware_hamiltonian import HardwareHamiltonian, HardwarePulse, AmplitudeAndPhase
  from pennylane.wires import Wires
  from pennylane.pulse.rydberg import RydbergSettings
label_desc: Use image node_id 2 for calling the TestRydbergDrive obj's underlying member method code with example usage: obj.test_multiple_local_drives() and returns: unknown, np