o
    0Gfx	                     @   sp   d Z ddlmZ ddlmZ ddlZddlmZ g d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|i | t| stdtD ]\}}t| d d |f | |< qd S )Nz4{} is required and must be passed to the constructor)super__init__hasattrAttributeErrorformat	enumerategetattr)selfargskwargsiZatt)	__class__	attributecolumns 9lib/python3.10/site-packages/statsmodels/tools/testing.pyr   !   s   
z,bunch_factory.<locals>.FactoryBunch.__init__)__name__
__module____qualname__r   __classcell__r   r   r   )r   r   FactoryBunch    s    r   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   s0    | ]\}}t |d  t |dd V  qdS z = r!   z
    N)strreplace.0kvr   r   r   	<genexpr>9       $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   s0    | ]\}}t |d  t|dd V  qdS r"   )r#   reprr$   r%   r   r   r   r)   ?   r*   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   r0   r2   r   r   r   r   r   1   s
    r    Tc                 K   sz   t |tjrt| | d S t |tjr tj| |fi | d S t |tjr2tj| |fi | d S t	j
| |ddd d S )Nr4   T)err_msgverbose)
isinstancepandasZIndexpdtZassert_index_equalZSeriesZassert_series_equalZ	DataFrameZassert_frame_equalnptassert_equal)ZactualZdesiredr5   r6   r    r   r   r   r;   G   s   r;   )r4   T)r3   Zstatsmodels.compat.pandasr   r9   Znumpy.testingr:   r8   Zstatsmodels.tools.toolsr   Z
PARAM_LISTr   ZParamsTableTestBunchZMarginTableTestBunchr   r;   r   r   r   r   <module>   s    

