def _iterate_columns(X, columns=None):
 if (columns is None):
  columns = range(X.shape[1])
 if issparse(X):
  for i in columns:
   x = np.zeros(X.shape[0])
   (start_ptr, end_ptr) = (X.indptr[i], X.indptr[(i + 1)])
   x[X.indices[start_ptr:end_ptr]] = X.data[start_ptr:end_ptr]
   (yield x)
 else:
  for i in columns:
   (yield X[:, i])

def _iterate_columns ( X , columns = None ) : if ( columns is None ) : columns = range ( X . shape [ 1 ] ) if issparse ( X ) : for i in columns : x = np . zeros ( X . shape [ 0 ] ) ( start_ptr , end_ptr ) = ( X . indptr [ i ] , X . indptr [ ( i + 1 ) ] ) x [ X . indices [ start_ptr : end_ptr ] ] = X . data [ start_ptr : end_ptr ] ( yield x ) else : for i in columns : ( yield X [ : , i ] )
iterate over columns of a matrix .