U
    Kvff                     @   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_fmtZtitle_alignZheader_alignZdata_alignsZstubs_alignfmtg           gDl
@)Zstub1Zstub2)Zheader1Z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   M/tmp/pip-unpacked-wheel-2v6byqio/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   r-   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   r-   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+   r.   r/   r   r   r   test_customlabel|   s    
z TestSimpleTable.test_customlabelN)r&   r'   r(   r0   r1   r8   r=   r   r   r   r   r)   @   s   r)   )__doc__Znumpyr   Znumpy.testingr   Z__docformat__Zstatsmodels.iolib.tabler   r   r   r   copyZltx_fmt1Z	html_fmt1dictr<   r   r   Zrow0datar    r9   r;   r:   r+   r   r   r)   r   r   r   r   <module>   sR     	