class_docstr: Unit tests for the ``drive`` function.
class_docstr_tok: ["Unit","tests","for","the","``","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"""
  
      def fa(p, t):
          return np.sin(p * t) / (2 * np.pi)
  
      H1 = drive(amplitude=fa, phase=1, wires=[0, 3])
      H2 = drive(amplitude=0.5 / np.pi, phase=3, wires=[1, 2])
      Hd = H1 + H2
  
      ops_expected = [
          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)]),
      ]
      coeffs_expected = [
          np.cos(3),
          np.sin(3),
          AmplitudeAndPhase(np.cos, fa, 1),
          AmplitudeAndPhase(np.sin, fa, 1),
      ]
      H_expected = HardwareHamiltonian(
          coeffs_expected, ops_expected, reorder_fn=_reorder_parameters
      )
  
      # structure of Hamiltonian is as expected
      assert isinstance(Hd, HardwareHamiltonian)
      assert Hd.wires == Wires([1, 2, 0, 3])
      assert Hd.settings is None
      assert len(Hd.ops) == 4  # 2 terms for amplitude/phase
  
      # coefficients are correct
      # Callable coefficients are shifted to the end of the list.
      assert Hd.coeffs[:2] == [np.cos(3), np.sin(3)]
      assert isinstance(Hd.coeffs[2], AmplitudeAndPhase)
      assert isinstance(Hd.coeffs[3], AmplitudeAndPhase)
  
      # pulses were added correctly
      assert Hd.pulses == []
  
      # Hamiltonian is as expected
      assert qml.equal(
          Hd([0.5, -0.5], t=5), H_expected([0.5, -0.5], t=5)
      )
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane.pulse import HardwareHamiltonian, drive, rydberg_interaction
  from pennylane.pulse.hardware_hamiltonian import HardwarePulse, AmplitudeAndPhase, amplitude_and_phase, _reorder_parameters
  from pennylane.pulse.transmon import TransmonSettings
  from pennylane.pulse.rydberg import RydbergSettings
  from pennylane.wires import Wires
label_desc: Use image node_id 2 for calling the TestDrive obj's underlying member method code with example usage: obj.test_multiple_local_drives() and returns: unknown