
    'YHh                         d dl Z d dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ  G d d      Zd Z G d	 d
      Zy)    N)assert_equal)summary_col)add_constant)OLSc                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)TestSummaryLatexc                     d}g d}t        |      }g d}g d}t        ||      j                         }t        ||      j                         }t        ||g      j	                         }d|z  }t        ||       y Na  
\begin{table}
\caption{}
\label{}
\begin{center}
\begin{tabular}{lll}
\hline
               & y I      & y II      \\
\hline
const          & 7.7500   & 12.4231   \\
               & (1.1058) & (3.1872)  \\
x1             & -0.7500  & -1.5769   \\
               & (0.2368) & (0.6826)  \\
R-squared      & 0.7697   & 0.6401    \\
R-squared Adj. & 0.6930   & 0.5202    \\
\hline
\end{tabular}
\end{center}
\end{table}
\bigskip
Standard errors in parentheses.
            r            r   r      r   r      r   z
%s
)r   r   fitr   as_latexr   selfdesiredxy1y2reg1reg2actuals           ^/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/iolib/tests/test_summary2.pytest_summarycolz TestSummaryLatex.test_summarycol   sr    , O2qz~~2qz~~dD\*335F"Wf%    c                 t   d}g d}t        |      }g d}g d}t        ||      j                         }t        ||      j                         }t        ||gd      j	                         }d|z  }t        ||gdd	      }d
t        |      v sJ dt        |      v sJ dt        |      vsJ t        ||       y )Na/  
==========================
                y I   y II
--------------------------
const          7.7   12.4 
               (1.1) (3.2)
x1             -0.7  -1.6 
               (0.2) (0.7)
R-squared      0.8   0.6  
R-squared Adj. 0.7   0.5  
==========================
Standard errors in
parentheses.
r   r   r   z%0.1ffloat_formatz%s
T)starsr'   z7.7***z12.4**z12.4***)r   r   r   r   as_textstrr   )	r   r   r   r   r   r   r    r!   starreds	            r"   test_summarycol_float_formatz-TestSummaryLatex.test_summarycol_float_format1   s     O2qz~~2qz~~dD\@HHJ&tTl$WM3w<'''3w<'''G,,,VW%r$   c           
         g d}t        |      }t        j                  |t        j                  dgdgdgdgdgg      gd      }g d}g d	}t	        ||      j                         }t	        ||      j                         }t        ||gd
dgd      }dt        |      vsJ t        ||gdgd      }d
t        |      v sJ dt        |      v sJ y )Nr   r   	   r   r   r   r   r   constx1T)regressor_orderdrop_omittedx2F)r   npconcatenatearrayr   r   r   r*   )r   r   r4   r   r   r   r    r!   s           r"   test_summarycol_drop_omittedz-TestSummaryLatex.test_summarycol_drop_omittedQ   s    O^^Q1#sRD1#s)C DEqI2qz~~2r{ dD\GT?*.03v;&&&dD\D6*/1#f+%%%s6{"""r$   c           
         g d}t        |      }t        j                  |t        j                  dgdgdgdgdgg      gd      }t	        j
                  |g d	      }g d
}g d}t        ||      j                         }t        ||      j                         }d d d}t        ||gd      x}}	t        ||gddgd|      }	d}
t        |      j                  d      D ]*  }|
D ]#  }|j                  |      s|t        |	      v r#J  , y )Nr   r   r.   r/   r   r   r   )r0   ba)columnsr   r   c                 0    t        | j                        dS )Nz.3f)intrsquaredr   s    r"   <lambda>zFTestSummaryLatex.test_summary_col_ordering_preserved.<locals>.<lambda>m   s    AJJ'< r$   c                 0    t        | j                        dS )Nd)r>   nobsr@   s    r"   rA   zFTestSummaryLatex.test_summary_col_ordering_preserved.<locals>.<lambda>n   s    s166{1o r$   )R2Nz%0.4fr&   r;   r:   )r2   r'   	info_dict
)r   r5   r6   r7   pd	DataFramer   r   r   r*   split
startswith)r   r   r4   r   r   r   r    rG   originalr!   	variableslinevariables                r"   #test_summary_col_ordering_preservedz4TestSummaryLatex.test_summary_col_ordering_preservedb   s   O^^Q1#sRD1#s)C DEqI\\"&9:2r{ 2r{ =68	't7KK6dD\C:*1'02 (	M''- 	/D% /??8,3v;.../	/r$   c                     d}g d}t        |      }g d}g d}t        ||      j                         }t        ||      j                         }t        ||g      j	                         }d|z  }t        ||       y r
   )r   r   r   r   _repr_latex_r   r   s           r"   test__repr_latex_z"TestSummaryLatex.test__repr_latex_y   sr    , O2qz~~2qz~~dD\*779F"VW%r$   c                 .   g d}t        |      }g d}t        ||      j                         }t        j                         5  t        j
                  d       |j                         j                         }d d d        d}|v }|du sJ y # 1 sw Y   xY w)Nr   r   ignorez\end{tabular}
\begin{tabular}T)r   r   r   warningscatch_warningssimplefiltersummaryr   )r   r   r   r   r!   string_to_findresults          r"   test_OLSsummaryz TestSummaryLatex.test_OLSsummary   s     O2qz~~$$& 	/!!(+\\^,,.F	/6)$	/ 	/s   4BBN)	__name__
__module____qualname__r#   r,   r8   rQ   rT   r]    r$   r"   r   r      s#     &D&@#"/. &D r$   r   c                     g d} g d}t        |t        |             j                         }d}t        j                  t
              5  |t        |j                               v sJ 	 d d d        t        j                  t
              5  |t        |j                               v sJ 	 d d d        t        || d      j                         }d}t        j                  t
              5  |t        |j                               v sJ 	 d d d        t        j                  t
              5  |t        |j                               v sJ 	 d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   bxY w# 1 sw Y   y xY w)N)r   r   r   r   r   r   r   r   )r   r   r   r   r   r.   
   r   z
R-squared:F)hasconstzR-squared (uncentered):)	r   r   r   pytestwarnsUserWarningr*   summary2rZ   )r   yreg_with_constantr2_strreg_without_constants        r"   test_ols_summary_rsquared_labelrm      sG    A!AA|A/335F	k	" ;.779::::;	k	" :.6689999: q!e488:&F	k	" >1::<====>	k	" =199;<<<<= =; ;: :
> >= =s0   EE%E%%E1EE"%E.1E:c                   ,    e Zd ZdZed        Zd Zd Zy)TestSummaryLabelsz@
    Test that the labels are correctly set in the summary tablec                 r    g ddz  }t        g ddz        }t        ||      j                         | _        y )N)r   r   r   r   r   )r   r   r   r   )endogexog)r   r   r   mod)clsri   r   s      r"   setup_classzTestSummaryLabels.setup_class   s2    1)*AA&**,r$   c                 n    t        | j                  d      }dt        |      v sJ dt        |      v sJ y )NTresults
include_r2zR-squared  R-squared Adj.r   rs   r*   r   tables     r"   test_summary_col_r2z%TestSummaryLabels.test_summary_col_r2   s6    DHH>E
***3u:---r$   c                 n    t        | j                  d      }dt        |      vsJ dt        |      vsJ y )NFrw   z	R-squaredrz   r{   r|   s     r"   test_absence_of_r2z$TestSummaryLabels.test_absence_of_r2   s6    DHH?#e*,,,s5z111r$   N)r^   r_   r`   __doc__classmethodru   r~   r   ra   r$   r"   ro   ro      s&    C - -
.2r$   ro   )rW   numpyr5   pandasrI   re   numpy.testingr   statsmodels.iolib.summary2r   statsmodels.tools.toolsr   #statsmodels.regression.linear_modelr   r   rm   ro   ra   r$   r"   <module>r      s9        & 2 0 3\  \ ~=&2 2r$   