ó
áp7]c        !   @@  sž  d  Z  d d l m Z d d l m 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 j ƒ  Z e j ƒ  Z e d
 d d g d d d d d d d d d d d d d d 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 d5 Z d6 Z e e e e d- e d. e d/ e ƒZ d0 „  Z d1 e f d2 „  ƒ  YZ d3 e f d4 „  ƒ  YZ d S(7   s  
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
i    (   t   absolute_import(   t   zipN(   t   assert_equals   restructuredtext en(   t   Cellt   SimpleTable(   t   default_latex_fmt(   t   default_html_fmtt	   data_fmtss   %0.2fs   %dt
   empty_cellt    t	   colwidthsi   t   colseps    * t   row_pres   * t   row_posts    *t   table_dec_abovet   *t   table_dec_belowt   header_dec_belowt
   header_fmts   %st   stub_fmtt   title_alignt   rt   header_alignt   data_alignst   stubs_alignt   lt   fmtt   txtg        i   gD‹lçû©
@t   stub1t   stub2t   header1t   header2t   txt_fmtt   ltx_fmtt   html_fmtc         C@  s   |  j  t j k r d Sd  S(   Nt   missing(   t   datat   npt   nan(   t   cell(    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyt   custom_labeller5   s    t   TestCellc           B@  s   e  Z d  „  Z RS(   c         C@  sƒ   t  t t d t d f } g  t | ƒ D]" \ } } t | d | d ƒ^ q' } x- t | | ƒ D] \ } } t | j | ƒ q_ Wd  S(   Ni    i   t   datatypei   (   t	   cell0datat	   cell1datat   row1datat	   enumerateR   R   R   R$   (   t   selft   celldatat   it   datumt   cellsR'   (    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyt   test_celldata;   s
    2(   t   __name__t
   __module__R4   (    (    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyR)   :   s   t   TestSimpleTablec           B@  s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C@  s'   d } d t  j ƒ  } t | | ƒ d  S(   Nsµ   
*****************************
*       * header1 * header2 *
*****************************
* stub1 *    0.00 *       1 *
* stub2 *    2.00 *       3 *
*****************************
s   
%s
(   t   tblt   as_textR   (   R/   t   desiredt   actual(    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyt   test_txt_fmt1D   s    	c         C@  s'   d } d t  j ƒ  } t | | ƒ d  S(   Ns	  
\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}
s   
%s
(   R8   t   as_latex_tabularR   (   R/   R:   R;   (    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyt   test_ltx_fmt1T   s    c         C@  sI   d } d t  j ƒ  } d j d „  | j d ƒ Dƒ ƒ } t | | ƒ d  S(   NsÜ   
<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>
s   
%s
s   
c         s@  s   |  ] } | j  ƒ  Vq d  S(   N(   t   rstrip(   t   .0t   line(    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pys	   <genexpr>y   s    (   R8   t   as_htmlt   joint   splitR   (   R/   R:   R;   (    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyt   test_html_fmt1g   s    "c         C@  sf   t  t t t d t ƒ} t j | d d _ | j t	 ƒ d } d | j
 d d ƒ } t | | ƒ d  S(   NR    i   sµ   
*****************************
*       * header1 * header2 *
*****************************
* stub1 *    --   *       1 *
* stub2 *    2.00 *       3 *
*****************************
s   
%s
R#   s   --(   R   t
   table1datat   test1headert
   test1stubst   txt_fmt1R%   R&   R$   t   label_cellsR(   R9   R   (   R/   R8   R:   R;   (    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyt   test_customlabel   s    	(   R5   R6   R<   R>   RE   RK   (    (    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyR7   C   s   			(   R   R   (   R   R   (    t   __doc__t
   __future__R    t   statsmodels.compat.pythonR   t   numpyR%   t   numpy.testingR   t   __docformat__t   statsmodels.iolib.tableR   R   R   R   t   copyt   ltx_fmt1t	   html_fmt1t   dictRI   R+   R,   t   row0dataR-   RF   RH   RG   R8   R(   t   objectR)   R7   (    (    (    sH   lib/python2.7/site-packages/statsmodels/iolib/tests/test_table_econpy.pyt   <module>   sN   			