class_docstr: Test the THermitian observable
class_docstr_tok: ["Test","the","THermitian","observable"]
docstr: Tests that the diagonalizing_gates method of the THermitian class keeps the same dictionary entries upon multiple calls.
docstr_tok: ["Tests","that","the","diagonalizing_gates","method","of","the","THermitian","class","keeps","the","same","dictionary","entries","upon","multiple","calls","."]
code: def test_thermitian_diagonalizing_gates_same_observable_twice(
      self, observable, eigvals, eigvecs, tol
  ):
      """Tests that the diagonalizing_gates method of the THermitian class keeps the same dictionary entries upon multiple calls."""
      qutrit_unitary = qml.THermitian(
          observable, wires=[0]
      ).diagonalizing_gates()
  
      key = tuple(observable.flatten().tolist())
      assert np.allclose(
          qml.THermitian._eigs[key]["eigval"], eigvals, atol=tol, rtol=0
      )
      assert np.allclose(
          qml.THermitian._eigs[key]["eigvec"], eigvecs, atol=tol, rtol=0
      )
  
      assert np.allclose(
          qutrit_unitary[0].data, eigvecs.conj().T, atol=tol, rtol=0
      )
      assert len(qml.THermitian._eigs) == 1
  
      qutrit_unitary = qml.THermitian(
          observable, wires=[0]
      ).diagonalizing_gates()
  
      key = tuple(observable.flatten().tolist())
      assert np.allclose(
          qml.THermitian._eigs[key]["eigval"], eigvals, atol=tol, rtol=0
      )
      assert np.allclose(
          qml.THermitian._eigs[key]["eigvec"], eigvecs, atol=tol, rtol=0
      )
  
      assert np.allclose(
          qutrit_unitary[0].data, eigvecs.conj().T, atol=tol, rtol=0
      )
      assert len(qml.THermitian._eigs) == 1
  
imports: import functools
  from unittest.mock import PropertyMock, patch
  import pytest
  import numpy
  from gate_data import GELL_MANN
  import pennylane
label_desc: Use image node_id 10 for calling the TestTHermitian obj's underlying member method code with example usage: obj.test_thermitian_diagonalizing_gates_same_observable_twice(observable, eigvals, eigvecs, tol) without return types