U
    Kvf	                     @   st   d Z ddlmZ ddlmZ ddlZddlmZ ddddgZ	d	d
 Z
e
de	Ze
de	ZG dd dZdddZdS )z0assert functions from numpy and pandas testing

    )testingNBunchparamsZbseZtvaluesZpvaluesc                    s   G  fdddt   S )a  
    Generates a special purpose Bunch class

    Parameters
    ----------
    attribute: str
        Attribute to access when splitting
    columns: List[str]
        List of names to use when splitting the columns of attribute

    Notes
    -----
    After the class is initialized as a Bunch, the columne of attribute
    are split so that Bunch has the keys in columns and
    bunch[column[i]] = bunch[attribute][:, i]
    c                       s"   e Zd Z fddZ  ZS )z#bunch_factory.<locals>.FactoryBunchc                    sZ   t  | j|| t| s*tdtD ]"\}}t| d d |f | |< q2d S )Nz5{0} is required and must be passed to the constructor)super__init__hasattrAttributeErrorformat	enumerategetattr)selfargskwargsiZatt)FactoryBunch	__class__	attributecolumns =/tmp/pip-unpacked-wheel-2v6byqio/statsmodels/tools/testing.pyr   !   s    
z,bunch_factory.<locals>.FactoryBunch.__init__)__name__
__module____qualname__r   __classcell__r   r   r   r   )r   r   r       s   r   r   )r   r   r   r   r   bunch_factory   s    	r   Zparams_tableZmargins_tablec                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	HolderzF
    Test-focused class to simplify accessing values by attribute
    c                 K   s   | j | d S )N)__dict__update)r   kwdsr   r   r   r   5   s    zHolder.__init__c                 C   s    d dd t|  D }|S )N
c                 s   s.   | ]&\}}t |d  t |dd V  qdS z = r!   z
    N)strreplace.0kvr   r   r   	<genexpr>9   s   z!Holder.__str__.<locals>.<genexpr>)joinvarsitemsr   ssr   r   r   __str__8   s    

zHolder.__str__c                 C   s2   d dd t|  D }t| jd | }|S )Nr!   c                 s   s.   | ]&\}}t |d  t|dd V  qdS r"   )r#   reprr$   r%   r   r   r   r)   ?   s   z"Holder.__repr__.<locals>.<genexpr>)r*   r+   r,   r#   r   r-   r   r   r   __repr__=   s
    

zHolder.__repr__N)r   r   r   __doc__r   r/   r1   r   r   r   r   r   1   s   r    Tc                 K   sl   t |tjrt| | nNt |tjr8tj| |f| n0t |tjrVtj| |f| nt	j
| |ddd d S )Nr3   T)err_msgverbose)
isinstancepandasZIndexpdtZassert_index_equalZSeriesZassert_series_equalZ	DataFrameZassert_frame_equalnptassert_equal)actualZdesiredr4   r5   r    r   r   r   r:   G   s    r:   )r3   T)r2   Zstatsmodels.compat.pandasr   r8   Znumpy.testingr9   r7   Zstatsmodels.tools.toolsr   Z
PARAM_LISTr   ZParamsTableTestBunchZMarginTableTestBunchr   r:   r   r   r   r   <module>   s   

