
    'YHh                     @    d Z ddlZddlmZmZ ddlZd Zd Z	d Z
d Zy)zTesting helper functions

Warning: current status experimental, mostly copy paste

Warning: these functions will be changed without warning as the need
during refactoring arises.

The first group of functions provide consistency checks

    N)assert_allcloseassert_c                     | }t        j                  t        |j                              }|j	                  |      }t        |j                  |j                  d       t        t        j                  |j                        |j                  d       t        t        j                  |j                        |j                  d       t        |j                  |j                  d       t        |j                         |j                         d       t        j                  |j                  |j                  |j                  |j                  |j                         f      }|j!                         j"                  }t        ||d       t%        t'        |d             |j	                  |d         }|j)                          t        j*                  |j                        }t        |j                  |d   d       y )N-q=rtolg|=&.>use_tr   )npeyelenparamst_testr   effectsqueezesdbsetvaluetvaluespvaluepvaluesconf_intcolumn_stacksummary_framevaluesr   hasattrsummaryasarray)resultsresmattt	table_restable2r   s          S/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/tools/_testing.pycheck_ttest_tvaluesr&      sL   
C
&&SZZ
!C	CBBIIszz6BJJruu%swwU;BJJryy)3;;UCBIIs{{7BKKM3<<>> SWWckk!$clln!> ?I&&FFIE2 GC!"	CF	BJJLjj%GBIIwqz6    c                    | }|j                   }t        |j                        }t        |      D cg c]6  }|j	                  t        j                  |      |   |d      j                  8 }}t        ||j                  dd       t        |      D cg c]5  }|j	                  t        j                  |      |   d      j                  7 }}t        ||j                  dd       |du rdnd	}t        |j                               }t        ||v        	 t        |j                               }t        ||v        y
c c}w c c}w # t        $ r Y y
w xY w)aN  
    Check that the outputs of `res.wald_test` produces pvalues that
    match res.pvalues.

    Check that the string representations of `res.summary()` and (possibly)
    `res.summary2()` correctly label either the t or z-statistic.

    Parameters
    ----------
    results : Results

    Raises
    ------
    AssertionError
    T)use_fscalarr	   g}:)r   atol)r*   FzP>|z|zP>|t|N)r
   r   r   range	wald_testr   r   r   r   r   strr   r   summary2AttributeError)	r   r    r
   k_varskpvalsstring_use_tsummsumm2s	            r%   check_ftest_pvaluesr7   /   s9     CIIE_F Fm% ]]266&>!,E$]GNN %E %E3;;U? Fm% ]]266&>!,T]:AA %E %E3;;U? $un7'Ls{{}DLD !'CLLN# 	%&+%
%  s   ;D?:EE	 		EEc                 F   dd l }ddlm} ddlm} t        | d|       } t        | ||f      r|j                  dt        |               | }|j                  }t        |j                  j                  |z
  |j                  d       t        ||j                         d       y )Nr   
GLMResultsDiscreteResults_resultszNot supported for r   r   )pytest+statsmodels.genmod.generalized_linear_modelr:   #statsmodels.discrete.discrete_modelr<   getattr
isinstanceskiptypefittedvaluesr   modelendogresidpredict)r   r>   r:   r<   r    fitteds         r%   check_fittedrK   [   s     GC gz73G'J89(g89
CFCIIOOf,ciieDFCKKM6r'   c                    | }t        j                  t        j                  |j                  j                  dd             }ddlm} ddlm} ddl	m
}m} t        | d|       } t        | ||f      rS|j                  |       |j                  |j                                |j                  |d   j                                y|j                   dd }t#        ||j                  |      d	       t#        ||j                  t        j                  |      j                               d	       t#        |dd
 |j                  |d   j                               d	       t#        |dd
 |j                  |d         d	       t%        t'        |            }|j                  |      }	|j(                  d
k(  rt*        j,                  nt*        j.                  }
|j                   |
||            }|	j(                  d
k(  rt*        j,                  nt*        j.                  }
 |
|	|      }t        |t*        j,                        r
 |||       y |||       y)z
    Check that the `predict` method of the given results object produces the
    correct output type.

    Parameters
    ----------
    results : Results

    Raises
    ------
    AssertionError
    N   r   r9   r;   )assert_frame_equalassert_series_equalr=   r   r      )index)r   r   r   rF   exogr?   r:   r@   r<   statsmodels.compat.pandasrN   rO   rA   rB   rI   tolistrE   r   r,   r   ndimpdSeries	DataFrame)r   r    p_exogr:   r<   rN   rO   rJ   
exog_index	predictedclspredicted_pandaspredicted_expecteds                r%   check_predict_typesr_   n   s    CZZ

399>>"1#567F GCQ gz73G'J89FFMMO$F1I$$&'!!"1%F 3%@BJJv,>,E,E,G H"	$ 	r
CKKq	0@0@0B$C"	$r
CKKq	$:"	$ 3v;'
KK'	!;;!+bii;;s6'DE %>>Q.biiBLL *=("))4 24DE13CDr'   )__doc__numpyr   numpy.testingr   r   pandasrV   r&   r7   rK   r_    r'   r%   <module>re      s+   	  2 7:)'X7&8Er'   