class_docstr: Test the Hermitian observable
class_docstr_tok: ["Test","the","Hermitian","observable"]
docstr: Tests that the eigvals method of the Hermitian class keeps the same dictionary entries upon multiple calls.
docstr_tok: ["Tests","that","the","eigvals","method","of","the","Hermitian","class","keeps","the","same","dictionary","entries","upon","multiple","calls","."]
code: def test_hermitian_eigvals_eigvecs_same_observable_twice(
      self, observable, eigvals, eigvecs, tol
  ):
      """Tests that the eigvals method of the Hermitian class keeps the same dictionary entries upon multiple calls."""
      key = tuple(observable.flatten().tolist())
  
      qml.Hermitian(observable, 0).eigvals()
      assert np.allclose(
          qml.Hermitian._eigs[key]["eigval"], eigvals, atol=tol, rtol=0
      )
      assert np.allclose(
          qml.Hermitian._eigs[key]["eigvec"], eigvecs, atol=tol, rtol=0
      )
      assert len(qml.Hermitian._eigs) == 1
  
      qml.Hermitian(observable, 0).eigvals()
      assert np.allclose(
          qml.Hermitian._eigs[key]["eigval"], eigvals, atol=tol, rtol=0
      )
      assert np.allclose(
          qml.Hermitian._eigs[key]["eigvec"], eigvecs, atol=tol, rtol=0
      )
      assert len(qml.Hermitian._eigs) == 1
  
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 7 for calling the TestHermitian obj's underlying member method code with example usage: obj.test_hermitian_eigvals_eigvecs_same_observable_twice(observable, eigvals, eigvecs, tol) without return types