U
    Ãmœdf  ã                   @   sä   d Z ddlZddlmZ dZddlmZmZ ddlm	Z	 ddlm
Z
 e	 ¡ Ze
 ¡ Zedd	gd
ddddddddddddddd�ZdZdZeegZddgZeegZdZdZeeeeeeed�Zdd„ ZG dd„ dƒZG dd „ d ƒZdS )!a  
Unit tests table.py.

:see: http://docs.python.org/lib/minimal-example.html for an intro to unittest
:see: http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-1-unittest.html
:see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305292
é    N)Úassert_equalzrestructuredtext en)ÚCellÚSimpleTable)Údefault_latex_fmt)Údefault_html_fmtz%0.2fz%dú é   z * z* z *Ú*z%sÚrÚlÚtxt)Z	data_fmtsZ
empty_cellZ	colwidthsZcolsepZrow_preZrow_postZtable_dec_aboveZtable_dec_belowZheader_dec_belowZ
header_fmtZstub_fmtÚtitle_alignZheader_alignZdata_alignsZstubs_alignÚfmtg        é   gD‹lçû©
@)Zstub1Zstub2)Úheader1Úheader2)Útxt_fmtZltx_fmtZhtml_fmtc                 C   s   | j tjkrdS d S )NÚmissing)ÚdataÚnpÚnan)Úcell© r   úb/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/statsmodels/iolib/tests/test_table_econpy.pyÚcustom_labeller2   s    r   c                   @   s   e Zd Zdd„ ZdS )ÚTestCellc                 C   sJ   t ttd td f}dd„ t|ƒD ƒ}t||ƒD ]\}}t|j|ƒ q0d S )Nr   r   c                 S   s    g | ]\}}t ||d  d�‘qS )r   )Údatatype)r   )Ú.0ÚiÚdatumr   r   r   Ú
<listcomp>:   s   ÿz*TestCell.test_celldata.<locals>.<listcomp>)Ú	cell0dataÚ	cell1dataÚrow1dataÚ	enumerateÚzipr   r   )ÚselfZcelldataÚcellsr   r   r   r   r   Útest_celldata8   s    ÿzTestCell.test_celldataN)Ú__name__Ú
__module__Ú__qualname__r(   r   r   r   r   r   7   s   r   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚTestSimpleTablec                 C   s   d}dt  ¡  }t||ƒ d S )Nzµ
*****************************
*       * header1 * header2 *
*****************************
* stub1 *    0.00 *       1 *
* stub2 *    2.00 *       3 *
*****************************
ú
%s
)ÚtblÚas_textr   ©r&   ÚdesiredÚactualr   r   r   Útest_txt_fmt1A   s    zTestSimpleTable.test_txt_fmt1c                 C   s   d}dt  ¡  }t||ƒ d S )Na	  
\begin{center}
\begin{tabular}{lcc}
\toprule
               & \textbf{header1} & \textbf{header2}  \\
\midrule
\textbf{stub1} &       0.0        &        1          \\
\textbf{stub2} &        2         &      3.333        \\
\bottomrule
\end{tabular}
\end{center}
r-   )r.   Zas_latex_tabularr   r0   r   r   r   Útest_ltx_fmt1Q   s    zTestSimpleTable.test_ltx_fmt1c                 C   s8   d}dt  ¡  }d dd„ | d¡D ƒ¡}t||ƒ d S )NzÜ
<table class="simpletable">
<tr>
    <td></td>    <th>header1</th> <th>header2</th>
</tr>
<tr>
  <th>stub1</th>   <td>0.0</td>      <td>1</td>
</tr>
<tr>
  <th>stub2</th>    <td>2</td>     <td>3.333</td>
</tr>
</table>
r-   Ú
c                 s   s   | ]}|  ¡ V  qd S )N)Úrstrip)r   Úliner   r   r   Ú	<genexpr>v   s     z1TestSimpleTable.test_html_fmt1.<locals>.<genexpr>)r.   Zas_htmlÚjoinÚsplitr   r0   r   r   r   Útest_html_fmt1d   s    zTestSimpleTable.test_html_fmt1c                 C   sL   t ttttd�}tj|d d _| t	¡ d}d|j
dd� }t||ƒ d S )N)r   r   zµ
*****************************
*       * header1 * header2 *
*****************************
* stub1 *    --   *       1 *
* stub2 *    2.00 *       3 *
*****************************
r-   z--)r   )r   Ú
table1dataÚtest1headerÚ
test1stubsÚtxt_fmt1r   r   r   Zlabel_cellsr   r/   r   )r&   r.   r1   r2   r   r   r   Útest_customlabel|   s    
z TestSimpleTable.test_customlabelN)r)   r*   r+   r3   r4   r;   r@   r   r   r   r   r,   @   s   r,   )Ú__doc__Únumpyr   Znumpy.testingr   Ú__docformat__Zstatsmodels.iolib.tabler   r   r   r   ÚcopyZltx_fmt1Z	html_fmt1Údictr?   r!   r"   Zrow0datar#   r<   r>   r=   r.   r   r   r,   r   r   r   r   Ú<module>   sR   ð  ÿ	