def _doktocsr(dok):
 (row, JA, A) = [list(i) for i in zip(*dok.row_list())]
 IA = ([0] * ((row[0] if row else 0) + 1))
 for (i, r) in enumerate(row):
  IA.extend(([i] * (r - row[(i - 1)])))
 IA.extend(([len(A)] * ((dok.rows - len(IA)) + 1)))
 shape = [dok.rows, dok.cols]
 return [A, JA, IA, shape]

def _doktocsr ( dok ) : ( row , JA , A ) = [ list ( i ) for i in zip ( * dok . row_list ( ) ) ] IA = ( [ 0 ] * ( ( row [ 0 ] if row else 0 ) + 1 ) ) for ( i , r ) in enumerate ( row ) : IA . extend ( ( [ i ] * ( r - row [ ( i - 1 ) ] ) ) ) IA . extend ( ( [ len ( A ) ] * ( ( dok . rows - len ( IA ) ) + 1 ) ) ) shape = [ dok . rows , dok . cols ] return [ A , JA , IA , shape ]
converts a sparse matrix to compressed sparse row format .