class_docstr: Test the Hermitian observable
class_docstr_tok: ["Test","the","Hermitian","observable"]
docstr: Tests that the hermitian matrix method raises the proper errors.
docstr_tok: ["Tests","that","the","hermitian","matrix","method","raises","the","proper","errors","."]
code: def test_hermitian_creation_exceptions(self):
      """Tests that the hermitian matrix method raises the proper errors."""
      ham = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
  
      # test non-square matrix
      with pytest.raises(ValueError, match="must be a square matrix"):
          qml.Hermitian(ham[1:], wires=0)
  
      H1 = np.array([[1]]) / np.sqrt(2)
  
      # test matrix with incorrect dimensions
      with pytest.raises(
          ValueError, match="Expected input matrix to have shape"
      ):
          qml.Hermitian(H1, wires=[0])
  
      # test non-Hermitian matrix
      H2 = ham.copy()
      H2[0, 1] = 2
      with pytest.raises(ValueError, match="must be Hermitian"):
          qml.Hermitian(H2, wires=0)
  
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 2 for calling the TestHermitian obj's underlying member method code with example usage: obj.test_hermitian_creation_exceptions() without return types