class_docstr: Tests for the expand_matrix helper function.
class_docstr_tok: ["Tests","for","the","expand_matrix","helper","function","."]
docstr: Tests that the method is used correctly by defining a dummy operator and
  checking the permutation/expansion.
docstr_tok: ["Tests","that","the","method","is","used","correctly","by","defining","a","dummy","operator","and","checking","the","permutation\/expansion","."]
code: def test_expand_matrix_usage_in_operator_class(self, tol):
      """Tests that the method is used correctly by defining a dummy operator and
      checking the permutation/expansion."""
  
      perm = [0, 2, 1, 3]
      permuted_matrix = self.base_matrix_2[perm][:, perm]
  
      expanded_matrix = np.array(
          [
              [1, 2, 0, 0, 3, 4, 0, 0],
              [5, 6, 0, 0, 7, 8, 0, 0],
              [0, 0, 1, 2, 0, 0, 3, 4],
              [0, 0, 5, 6, 0, 0, 7, 8],
              [9, 10, 0, 0, 11, 12, 0, 0],
              [13, 14, 0, 0, 15, 16, 0, 0],
              [0, 0, 9, 10, 0, 0, 11, 12],
              [0, 0, 13, 14, 0, 0, 15, 16],
          ]
      )
  
      class DummyOp(qml.operation.Operator):
          num_wires = 2
  
          @staticmethod
          def compute_matrix():
              return self.base_matrix_2
  
      op = DummyOp(wires=[0, 2])
      assert np.allclose(op.matrix(), self.base_matrix_2, atol=tol)
      assert np.allclose(
          op.matrix(wire_order=[2, 0]), permuted_matrix, atol=tol
      )
      assert np.allclose(
          op.matrix(wire_order=[0, 1, 2]), expanded_matrix, atol=tol
      )
  
imports: from functools import reduce
  import numpy
  import pytest
  from gate_data import CNOT, II, SWAP, I, Toffoli
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 25 for calling the TestExpandMatrix obj's underlying member method code with example usage: obj.test_expand_matrix_usage_in_operator_class(tol) and returns: self