U
    Kvf                     @   s   d dl ZdddZdS )    Nc                 C   s   t | tjr| jdkr| j} t| }t| d }|sDt| d j}tj||f|d}d}d}g }g }	g }
t	| |D ]N\}}||dd|f< tj
|}||kr|| |}|d7 }qt|	| qt|ddd|f |fS )z
    construct array with independent columns

    x is either iterable (list, tuple) or instance of ndarray or a subclass
    of it.  If x is an ndarray, then each column is assumed to represent a
    variable with observations in rows.
       r   )dtypeN   )
isinstancenpZndarrayndimTlenZasarrayr   zeroszipZlinalgZmatrix_rankappend)xvarnamesr   Z
nvars_origZnobsZxoutcountZrank_oldZvarnames_newZvarnames_droppedZkeepindxxiniZrank_new r   </tmp/pip-unpacked-wheel-2v6byqio/statsmodels/tools/catadd.py	add_indep   s*    


r   )N)Znumpyr   r   r   r   r   r   <module>   s   