class_docstr: Test the THermitian observable
class_docstr_tok: ["Test","the","THermitian","observable"]
docstr: Tests that the diagonalizing_gates method of the THermitian class returns the correct results
  for two observables.
docstr_tok: ["Tests","that","the","diagonalizing_gates","method","of","the","THermitian","class","returns","the","correct","results","for","two","observables","."]
code: def test_thermitian_diagonalizing_gates_two_different_observables(
      self, obs1, obs2, tol
  ):
      """Tests that the diagonalizing_gates method of the THermitian 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]
  
      qutrit_unitary = qml.THermitian(
          observable_1, wires=[0]
      ).diagonalizing_gates()
  
      key = tuple(observable_1.flatten().tolist())
      assert np.allclose(
          qml.THermitian._eigs[key]["eigval"],
          observable_1_eigvals,
          atol=tol,
          rtol=0,
      )
      assert np.allclose(
          qml.THermitian._eigs[key]["eigvec"],
          observable_1_eigvecs,
          atol=tol,
          rtol=0,
      )
  
      assert np.allclose(
          qutrit_unitary[0].data,
          observable_1_eigvecs.conj().T,
          atol=tol,
          rtol=0,
      )
      assert len(qml.THermitian._eigs) == 1
  
      observable_2 = obs2[0]
      observable_2_eigvals = obs2[1]
      observable_2_eigvecs = obs2[2]
  
      qutrit_unitary_2 = qml.THermitian(
          observable_2, wires=[0]
      ).diagonalizing_gates()
  
      key = tuple(observable_2.flatten().tolist())
      assert np.allclose(
          qml.THermitian._eigs[key]["eigval"],
          observable_2_eigvals,
          atol=tol,
          rtol=0,
      )
      assert np.allclose(
          qml.THermitian._eigs[key]["eigvec"],
          observable_2_eigvecs,
          atol=tol,
          rtol=0,
      )
  
      assert np.allclose(
          qutrit_unitary_2[0].data,
          observable_2_eigvecs.conj().T,
          atol=tol,
          rtol=0,
      )
      assert len(qml.THermitian._eigs) == 2
  
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 9 for calling the TestTHermitian obj's underlying member method code with example usage: obj.test_thermitian_diagonalizing_gates_two_different_observables(obs1, obs2, tol) without return types