class_docstr: Tests for the _sparse_expand_matrix function.
class_docstr_tok: ["Tests","for","the","_sparse_expand_matrix","function","."]
docstr: Tests the case where the original matrix is expanded
docstr_tok: ["Tests","the","case","where","the","original","matrix","is","expanded"]
code: def test_expansion(self):
      """Tests the case where the original matrix is expanded"""
      res = qml.math.expand_matrix(
          self.base_matrix_1, wires=[2], wire_order=[0, 2]
      )
      res.sort_indices()
      expected = csr_matrix(
          np.array(
              [[1, 2, 0, 0], [3, 4, 0, 0], [0, 0, 1, 2], [0, 0, 3, 4]]
          )
      )
      expected.sort_indices()
  
      assert isinstance(res, type(expected))
      assert all(res.data == expected.data)
      assert all(res.indices == expected.indices)
  
      res = qml.math.expand_matrix(
          self.base_matrix_1, wires=[2], wire_order=[2, 0]
      )
      res.sort_indices()
      expected = csr_matrix(
          np.array(
              [[1, 0, 2, 0], [0, 1, 0, 2], [3, 0, 4, 0], [0, 3, 0, 4]]
          )
      )
      expected.sort_indices()
  
      assert isinstance(res, type(expected))
      assert all(res.data == expected.data)
      assert all(res.indices == expected.indices)
  
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 5 for calling the TestExpandMatrixSparse obj's underlying member method code with example usage: obj.test_expansion() without return types