class_docstr: Test the Hermitian observable
class_docstr_tok: ["Test","the","Hermitian","observable"]
docstr: Tests that the eigvals method of the Hermitian class returns the correct results
  for two observables.
docstr_tok: ["Tests","that","the","eigvals","method","of","the","Hermitian","class","returns","the","correct","results","for","two","observables","."]
code: def test_hermitian_eigvals_eigvecs_two_different_observables(
      self, obs1, obs2, tol
  ):
      """Tests that the eigvals method of the Hermitian class returns the correct results
      for two observables."""
      if np.all(obs1[0] == obs2[0]):
          pytest.skip(
              "Test only runs for pairs of differing observable"
          )
  
      observable_1 = obs1[0]
      observable_1_eigvals = obs1[1]
      observable_1_eigvecs = obs1[2]
  
      key = tuple(observable_1.flatten().tolist())
  
      qml.Hermitian(observable_1, 0).eigvals()
      assert np.allclose(
          qml.Hermitian._eigs[key]["eigval"],
          observable_1_eigvals,
          atol=tol,
          rtol=0,
      )
      assert np.allclose(
          qml.Hermitian._eigs[key]["eigvec"],
          observable_1_eigvecs,
          atol=tol,
          rtol=0,
      )
      assert len(qml.Hermitian._eigs) == 1
  
      observable_2 = obs2[0]
      observable_2_eigvals = obs2[1]
      observable_2_eigvecs = obs2[2]
  
      key_2 = tuple(observable_2.flatten().tolist())
  
      qml.Hermitian(observable_2, 0).eigvals()
      assert np.allclose(
          qml.Hermitian._eigs[key_2]["eigval"],
          observable_2_eigvals,
          atol=tol,
          rtol=0,
      )
      assert np.allclose(
          qml.Hermitian._eigs[key_2]["eigvec"],
          observable_2_eigvecs,
          atol=tol,
          rtol=0,
      )
      assert len(qml.Hermitian._eigs) == 2
  
imports: import functools
  import pickle
  import pytest
  import numpy
  from gate_data import I, X, Y, Z, H
  import pennylane
  from pennylane.ops.qubit.observables import BasisStateProjector, StateVectorProjector
label_desc: Use image node_id 6 for calling the TestHermitian obj's underlying member method code with example usage: obj.test_hermitian_eigvals_eigvecs_two_different_observables(obs1, obs2, tol) without return types