class_docstr: Tests for simple single-qutrit observables
class_docstr_tok: ["Tests","for","simple","single-qutrit","observables"]
docstr: Test the method transforms Gell-Mann observables appropriately.
docstr_tok: ["Test","the","method","transforms","Gell-Mann","observables","appropriately","."]
code: def test_diagonalization(self, index, mat, eigs, tol):
      """Test the method transforms Gell-Mann observables appropriately."""
      ob = qml.GellMann(wires=0, index=index)
      A = ob.matrix()
  
      diag_gates = ob.diagonalizing_gates()
      U = np.eye(3)
  
      if index in {3, 8}:
          assert len(diag_gates) == 0
      else:
          assert len(diag_gates) == 1
          assert diag_gates[0].__class__ == qml.QutritUnitary
          mat = diag_gates[0].matrix()
          U = np.dot(np.eye(3), mat)
  
      res = U @ A @ U.conj().T
      expected = np.diag(eigs)
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
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 1 for calling the TestGellMann obj's underlying member method code with example usage: obj.test_diagonalization(index, mat, eigs, tol) without return types