class_docstr: Tests for the hamiltonian_expand transform
class_docstr_tok: ["Tests","for","the","hamiltonian_expand","transform"]
docstr: Tests that the hamiltonian_expand transform raises an error for a Hamiltonian with no terms.
docstr_tok: ["Tests","that","the","hamiltonian_expand","transform","raises","an","error","for","a","Hamiltonian","with","no","terms","."]
code: def test_ham_with_no_terms_raises(self):
      """Tests that the hamiltonian_expand transform raises an error for a Hamiltonian with no terms."""
      mps = [qml.expval(qml.Hamiltonian([], []))]
      qscript = QuantumScript([], mps)
  
      with pytest.raises(
          ValueError,
          match="The Hamiltonian in the tape has no terms defined - cannot perform the Hamiltonian expansion.",
      ):
          qml.transforms.hamiltonian_expand(qscript)
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.queuing import AnnotatedQueue
  from pennylane.tape import QuantumScript
  from pennylane.transforms import hamiltonian_expand, sum_expand
label_desc: Use image node_id 1 for calling the TestHamiltonianExpand obj's underlying member method code with example usage: obj.test_ham_with_no_terms_raises() without return types