class_docstr: Test the new VQE syntax of passing the Hamiltonian as an observable.
class_docstr_tok: ["Test","the","new","VQE","syntax","of","passing","the","Hamiltonian","as","an","observable","."]
docstr: Tests that error is thrown if sample(H) is measured.
docstr_tok: ["Tests","that","error","is","thrown","if","sample","(","H",")","is","measured","."]
code: def test_error_sample_measurement(self):
      """Tests that error is thrown if sample(H) is measured."""
      observables = [qml.PauliZ(0), qml.PauliY(0), qml.PauliZ(1)]
      coeffs = [1.0] * len(observables)
      dev = qml.device("default.qubit", wires=2, shots=10)
      H = qml.Hamiltonian(coeffs, observables)
  
      @qml.qnode(dev)
      def circuit():
          return qml.sample(H)
  
      with pytest.raises(qml.operation.DiagGatesUndefinedError):
          circuit()
  
imports: import copy
  import numpy
  import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 8 for calling the TestNewVQE obj's underlying member method code with example usage: obj.test_error_sample_measurement() and returns: qml