code: def test_dummy_sparse():
      # See GH#5687
  
      g = np.array([0, 0, 2, 1, 1, 2, 0])
      indi = dummy_sparse(g)
      assert isinstance(indi, sparse.csr_matrix)
      result = indi.todense()
      expected = np.matrix(
          [
              [1, 0, 0],
              [1, 0, 0],
              [0, 0, 1],
              [0, 1, 0],
              [0, 1, 0],
              [0, 0, 1],
              [1, 0, 0],
          ],
          dtype=np.int8,
      )
      assert_equal(result, expected)
  
      # current behavior with missing groups
      g = np.array([0, 0, 2, 0, 2, 0])
      indi = dummy_sparse(g)
      result = indi.todense()
      expected = np.matrix(
          [
              [1, 0, 0],
              [1, 0, 0],
              [0, 0, 1],
              [1, 0, 0],
              [0, 0, 1],
              [1, 0, 0],
          ],
          dtype=np.int8,
      )
      assert_equal(result, expected)
  
imports: from statsmodels.compat.pandas import assert_frame_equal, assert_series_equal
  import numpy
  from numpy.testing import assert_equal
  import pandas
  import pytest
  from scipy import sparse
  from statsmodels.tools.grouputils import dummy_sparse, Grouping, Group, combine_indices, group_sums
  from statsmodels.datasets import grunfeld, anes96
label_desc: Use image node_id 5 for calling a global function with example usage: test_dummy_sparse() without return types