class_docstr: Tests for the basis state projector observable.
class_docstr_tok: ["Tests","for","the","basis","state","projector","observable","."]
docstr: Test that the matrix representation is defined correctly
docstr_tok: ["Test","that","the","matrix","representation","is","defined","correctly"]
code: def test_matrix_representation(
      self, basis_state, expected, n_wires, tol
  ):
      """Test that the matrix representation is defined correctly"""
      res_dynamic = qml.Projector(
          basis_state, wires=range(n_wires)
      ).matrix()
      res_static = BasisStateProjector.compute_matrix(basis_state)
      assert np.allclose(res_dynamic, expected, atol=tol)
      assert np.allclose(res_static, expected, atol=tol)
  
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 4 for calling the TestBasisStateProjector obj's underlying member method code with example usage: obj.test_matrix_representation(basis_state, expected, n_wires, tol) without return types