#NEWLINE# def add_indep( x , varnames , dtype = None ) : #NEWLINE# #INDENT# '\n    construct array with independent columns\n\n    x is either iterable (list, tuple) or instance of ndarray or a subclass of it.\n    If x is an ndarray, then each column is assumed to represent a variable with\n    observations in rows.\n    ' #NEWLINE# if ( isinstance ( x , np . ndarray ) and ( x . ndim == 2 ) ) : #NEWLINE# #INDENT# x = x . T #NEWLINE# #UNINDENT# nvars_orig = len ( x ) #NEWLINE# nobs = len ( x [ 0 ] ) #NEWLINE# if ( not dtype ) : #NEWLINE# #INDENT# dtype = np . asarray ( x [ 0 ] ) . dtype #NEWLINE# #UNINDENT# xout = np . zeros ( ( nobs , nvars_orig ) , dtype = dtype ) #NEWLINE# count = 0 #NEWLINE# rank_old = 0 #NEWLINE# varnames_new = [ ] #NEWLINE# varnames_dropped = [ ] #NEWLINE# keepindx = [ ] #NEWLINE# for ( xi , ni ) in zip ( x , varnames ) : #NEWLINE# #INDENT# xout [ : , count ] = xi #NEWLINE# rank_new = np_matrix_rank ( xout ) #NEWLINE# if ( rank_new > rank_old ) : #NEWLINE# #INDENT# varnames_new . append ( ni ) #NEWLINE# rank_old = rank_new #NEWLINE# count += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# varnames_dropped . append ( ni ) #NEWLINE# #UNINDENT# #UNINDENT# return ( xout [ : , : count ] , varnames_new )