code: def from_sparse(m, order=None, out=None):
          
  
          import scipy.sparse
  
          # check arguments
          if not scipy.sparse.isspmatrix(m):
              raise ValueError('not a sparse matrix: %r' % m)
  
          # convert to dense array
          data = m.toarray(order=order, out=out)
  
          # wrap
          h = HaplotypeArray(data)
  
          return h
docs: Construct a haplotype array from a sparse matrix.
  
          Parameters
          ----------
          m : scipy.sparse.spmatrix
              Sparse matrix
          order : {'C', 'F'}, optional
              Whether to store data in C (row-major) or Fortran (column-major)
              order in memory.
          out : ndarray, shape (n_variants, n_samples), optional
              Use this array as the output buffer.
  
          Returns
          -------
          h : HaplotypeArray, shape (n_variants, n_haplotypes)
              Haplotype array.
  
          Examples
          --------
  
          >>> import allel
          >>> import numpy as np
          >>> import scipy.sparse
          >>> data = np.array([ 1,  1,  1,  1, -1, -1], dtype=np.int8)
          >>> indices = np.array([1, 3, 0, 1, 2, 3], dtype=np.int32)
          >>> indptr = np.array([0, 0, 2, 4, 6], dtype=np.int32)
          >>> m = scipy.sparse.csr_matrix((data, indices, indptr))
          >>> h = allel.HaplotypeArray.from_sparse(m)
          >>> h
          <HaplotypeArray shape=(4, 4) dtype=int8>
          0 0 0 0
          0 1 0 1
          1 1 0 0
          0 0 . .