code: def to_sparse(self, format='csr', **kwargs):
          
  
          h = self.to_haplotypes()
          m = h.to_sparse(format=format, **kwargs)
          return m
docs: Convert into a sparse matrix.
  
          Parameters
          ----------
          format : {'coo', 'csc', 'csr', 'dia', 'dok', 'lil'}
              Sparse matrix format.
          kwargs : keyword arguments
              Passed through to sparse matrix constructor.
  
          Returns
          -------
          m : scipy.sparse.spmatrix
              Sparse matrix
  
          Notes
          -----
  
          If a mask has been set, it is ignored by this function.
  
          Examples
          --------
  
          >>> import allel
          >>> g = allel.GenotypeArray([[[0, 0], [0, 0]],
          ...                          [[0, 1], [0, 1]],
          ...                          [[1, 1], [0, 0]],
          ...                          [[0, 0], [-1, -1]]], dtype='i1')
          >>> m = g.to_sparse(format='csr')
          >>> m
          <4x4 sparse matrix of type '<class 'numpy.int8'>'
              with 6 stored elements in Compressed Sparse Row format>
          >>> m.data
          array([ 1,  1,  1,  1, -1, -1], dtype=int8)
          >>> m.indices
          array([1, 3, 0, 1, 2, 3], dtype=int32)
          >>> m.indptr
          array([0, 0, 2, 4, 6], dtype=int32)