class_docstr: Test expectation values
class_docstr_tok: ["Test","expectation","values"]
docstr: Test that arbitrary Hermitian expectation values are correct
code: def test_hermitian_expectation(self, device, tol):
      """Test that arbitrary Hermitian expectation values are correct"""
      n_wires = 2
      dev = device(n_wires)
  
      if "Hermitian" not in dev.observables:
          pytest.skip(
              "Skipped because device does not support the Hermitian observable."
          )
  
      theta = 0.432
      phi = 0.123
  
      @qml.qnode(dev)
      def circuit():
          qml.RY(theta, wires=[0])
          qml.RY(phi, wires=[1])
          qml.CNOT(wires=[0, 1])
          return qml.expval(qml.Hermitian(A, wires=0)), qml.expval(
              qml.Hermitian(A, wires=1)
          )
  
      res = circuit()
  
      a = A[0, 0]
      re_b = A[0, 1].real
      d = A[1, 1]
      ev1 = (
          (a - d) * np.cos(theta)
          + 2 * re_b * np.sin(theta) * np.sin(phi)
          + a
          + d
      ) / 2
      ev2 = (
          (a - d) * np.cos(theta) * np.cos(phi)
          + 2 * re_b * np.sin(phi)
          + a
          + d
      ) / 2
      expected = np.array([ev1, ev2])
  
      assert np.allclose(res, expected, atol=tol(dev.shots))
  
imports: import pytest
  from flaky import flaky
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import numpy
  from pennylane.measurements import ClassicalShadowMP, MeasurementTransform, SampleMeasurement, SampleMP, StateMeasurement, StateMP
label_desc: Use image node_id 6 for calling the TestExpval obj's underlying member method code with example usage: obj.test_hermitian_expectation(device, tol) and returns: qml,  qml