class_docstr: Unit tests for the properties of the HardwareHamiltonian class.
class_docstr_tok: ["Unit","tests","for","the","properties","of","the","HardwareHamiltonian","class","."]
docstr: Test that adding a scalar/number to a `HardwareHamiltonian` works as expected.
docstr_tok: ["Test","that","adding","a","scalar\/number","to","a","`","HardwareHamiltonian","`","works","as","expected","."]
code: def test_add_scalar(self, scalars):
      """Test that adding a scalar/number to a `HardwareHamiltonian` works as expected."""
      coeffs = [2, 3]
      ops = [qml.PauliZ(2), qml.PauliX(0)]
  
      H = HardwareHamiltonian(
          coeffs=coeffs,
          observables=ops,
          pulses=[HardwarePulse(qml.pulse.constant, 6, 7, 8)],
      )
      orig_matrix = qml.matrix(H([0.3], 0.1))
      H1 = H + scalars[0]
      assert len(H1.ops) == len(H1.coeffs) == 3
      assert qml.equal(H1.ops[-1], qml.Identity(2))
      assert qml.math.allclose(
          qml.matrix(H1([0.3], 0.1)),
          orig_matrix + np.eye(4) * scalars[0],
      )
      H2 = scalars[1] + H1
      assert len(H2.ops) == len(H2.coeffs) == 4
      assert qml.equal(H2.ops[-2], qml.Identity(2))
      assert qml.equal(H2.ops[-1], qml.Identity(2))
      assert qml.math.allclose(
          qml.matrix(H2([0.3], 0.1)),
          orig_matrix + np.eye(4) * (scalars[0] + scalars[1]),
      )
      H += scalars[0]
      assert len(H.ops) == len(H.coeffs) == 3
      assert qml.equal(H.ops[-1], qml.Identity(2))
      assert qml.math.allclose(
          qml.matrix(H([0.3], 0.1)),
          orig_matrix + np.eye(4) * scalars[0],
      )
  
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 6 for calling the TestHardwareHamiltonian obj's underlying member method code with example usage: obj.test_add_scalar(scalars) without return types