
    M/Ph#1                     j   d dl mZ d dlZd dlZd dlZd dlmZm	Z	m
Z
mZmZmZmZ d dlmZ  ej        ddg          d             Zd	 Z G d
 d          Zd Zd Zd Zd Z G d de          Z ej        eeedf          d             Zd Zd Zd Zd Z ej        dd ej         d           ej!        dg          df          d             Z" ej         ej#        d          ddddf          d             Z$d  Z%d! Z& ej        dd ej         d"           ej!        d#g          f          d$             Z' ej        d% ej         d%          d& e(d'          d(d) ej)        d          f          d*             Z*d+ Z+d, Z, ej        g d-          d.             Z-d/ Z.d0 Z/dS )1    )OrderedDictN)
array_likePandasWrapper	bool_like	dict_like
float_likeint_likestring_like)_right_squeezeTF)paramsc                     | j         S Nparamrequests    r/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/tools/validation/tests/test_validation.py
use_pandasr      
    =    c                    | dk    r+t          j        d          }|rt          j        |          }n[| dk    r+t          j        d          }|rt          j        |          }n*t          j        t          j        dd| z                       }|S )N   
         r      )npemptypdSeries	DataFramearange)dimr   outs      r   gen_datar&      s    
axxhrmm 	!)C..C	hx   	$,s##ChryAG,,--Jr   c                       e Zd Zd Zd Zd Zd Zd Zd Ze	j
                            d          d	             Zd
 ZdS )TestArrayLikec                 V   t          d|          }t          |d          }|j        dk    sJ |j        dk    sJ t	          |          t
          j        u sJ t          |dd          }|j        dk    sJ t          |dd          }|j        dk    sJ t          |ddd          }|j        dk    sJ t          |ddd	          }|j        dk    sJ |j        d	k    sJ t          j        t          d
          5  t          |dd           d d d            d S # 1 swxY w Y   d S )Nr   ar   ndim)shaper   r-   r.   r   )r   r   a is required to have shapematch)r   
r&   r   r-   r.   typer   ndarraypytestraises
ValueErrorselfr   datar*   s       r   test_1dzTestArrayLike.test_1d)   s   :&&tS!!v{{{{w%Aww"*$$$$tSq)))v{{{{tS...w%tSq888v{{{{tSq888v{{{{w'!!!!]:-JKKK 	. 	.tS----	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   >DD"%D"c                    t          d|          }t          |dd          }|j        dk    sJ |j        dk    sJ t	          |          t
          j        u sJ t          |dd          }|j        dk    sJ t          |ddd          }|j        dk    sJ t          |ddd          }|j        dk    sJ t          |ddd          }|j        dk    sJ t          |ddd	          }|j        dk    sJ t          |dd
          }|j        d
k    sJ |j        dk    sJ t          j        t          d          5  t          |ddd           d d d            n# 1 swxY w Y   t          j        t          d          5  t          |ddd           d d d            n# 1 swxY w Y   t          j        t          d          5  t          |ddd           d d d            n# 1 swxY w Y   d}t          j        t          |          5  t          |dd           d d d            n# 1 swxY w Y   d}t          j        t          |          5  t          |dd           d d d            d S # 1 swxY w Y   d S )Nr   r*   r,   r   )r   Nr/   )r   )Nr   )NN   )r   r   r   r0   r1   r+   )r   r   )Nr   z+a is required to have ndim 1 but has ndim 2r   a must have ndim <= 1maxdimr3   )r:   r   r;   r*   r2   s        r   test_2dzTestArrayLike.test_2d=   s   :&&tSq)))v{{{{w(""""Aww"*$$$$tSq)))v{{{{tSq
;;;w(""""tSq666w(""""tSq
;;;w(""""tSq===v{{{{tSq)))v{{{{w+%%%%]:-JKKK 	7 	7tSq6666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7]:-JKKK 	: 	:tSq9999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:]:-JKKK 	< 	<tSq
;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<=]:U333 	* 	*tSq))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*']:U333 	, 	,tS++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,sZ    E  E$'E$F&&F*-F*G,,G03G0H33H7:H7I;;I?I?c                 :   t          dd          }t          |dd          }|j        dk    sJ |j        dk    sJ t	          |          t
          j        u sJ t          |ddd          }|j        dk    sJ t          |ddd          }|j        dk    sJ t          |dd	          }|j        d
k    sJ t          j        t          d          5  t          |ddd           d d d            n# 1 swxY w Y   t          j        t          d          5  t          |ddd           d d d            n# 1 swxY w Y   d}t          j        t          |          5  t          |dd           d d d            n# 1 swxY w Y   d}t          j        t          |          5  t          |dd           d d d            n# 1 swxY w Y   d}t          j        t          |          5  t          |dd           d d d            d S # 1 swxY w Y   d S )Nr>   Fr*   r,   )r         )r   NrE   r/   )NNrE   r   )r   rD   rE   r   r   r0   r1   r+   )NNr   z+a is required to have ndim 2 but has ndim 3r   r?   r   r@   za must have ndim <= 2)
r&   r   r.   r-   r4   r   r5   r6   r7   r8   )r:   r;   r*   r2   s       r   test_3dzTestArrayLike.test_3d`   s   5!!tSq)))w)####v{{{{Aww"*$$$$tSq===w)####tSq@@@w)####tSq)))w/))))]:-JKKK 	7 	7tSq6666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7]:-JKKK 	A 	AtSq@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A=]:U333 	* 	*tSq))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*']:U333 	, 	,tS++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,']:U333 	, 	,tS++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,sZ   C44C8;C8D::D>D>"FFF)GGG0HHHc                 N   t          j        d          }t          |dd          }|j        dk    sJ t          j        d          }t          |dd          }|j        dk    sJ t          j        d          }t          |dd          }|j        dk    sJ t          j        d          }t          |dd          }|j        dk    sJ t          j        d	          }t	          j        t                    5  t          |dd           d d d            d S # 1 swxY w Y   d S )
N)r   r   r   r*   r>   r,   r   )r   r   r   )r   r   )r   r   r   r   )r   r   r   r   r   r   )r   r   r   r.   r6   r7   r8   )r:   r;   r*   s      r   test_right_squeeze_and_padz(TestArrayLike.test_right_squeeze_and_pad{   sq   x	""tSq)))w)####x{{tSq)))w)####xtSq)))w)####x%%tSq)))w)####x*++]:&& 	* 	*tSq))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   :DD!Dc                     t          j        d          }|d d d         }t          |dd          }|j        d         rJ |j        d         sJ d S )Nr   r   r*   T)
contiguousC_CONTIGUOUS)r   r#   r   flags)r:   xyr*   s       r   test_contiguouszTestArrayLike.test_contiguous   s^    IbMMcccFq#$///7>****w~&&&&&&r   c                     t          j        d          }t          |dt           j                  }|j        t           j        k    sJ t          |dt           j                  }|j        t           j        k    sJ d S )Nr   r*   )dtype)r   r#   r   float32rQ   uint8)r:   rM   r*   s      r   
test_dtypezTestArrayLike.test_dtype   sk    IbMMq#RZ000w"*$$$$q#RX...w"(""""""r   zFailing for now)reasonc                    t          d|          }t          |d          }t          |j                            |          t                    rJ t          |j                            |          t                    rJ d S )Nr   r*   )r&   r   
isinstanceTdotr9   s       r   test_dotzTestArrayLike.test_dot   sj    :&&tS!!acggdmmZ88888acggajj*5555555r   c                     t          d|          }t          |dd          }t          |dd                    t          j        u sJ d S )Nr   r*   r,   r   )r&   r   r4   r   r5   r9   s       r   
test_slicezTestArrayLike.test_slice   sL    :&&tSq)))AabbE{{bj((((((r   N)__name__
__module____qualname__r<   rB   rF   rH   rO   rT   r6   markxfailrZ   r\    r   r   r(   r(   (   s        . . .(!, !, !,F, , ,6* * *&' ' '# # # [/006 6 106) ) ) ) )r   r(   c                     t          j        d          } t          |           }|j        dk    sJ t          j        d          } t          |           }|j        dk    sJ t          j        d          } t          |           }|j        dk    sJ t          j        d          } t          |           }|j        dk    sJ d S )N)r   r   r   )r   r   r   )r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r.   )rM   rN   s     r   test_right_squeezerd      s    
AqA7k!!!!
AqA7h
())AqA7h
+,,AqA7k!!!!!!r   c                 2   t          d|           }t          dd          }t          |                              |          }| rt          j        nt
          j        }t          ||          sJ | r	|j        J t          |                              |d          }t          ||          sJ | r|j        dk    sJ t          |                              |dg          }t          ||          sJ | r|j        dk    sJ | rt          j	        nt
          j        }t          |                              |d d d f                   }t          ||          sJ | r|j
        d         dk    sJ t          |                              |d d d f         dg          }t          ||          sJ | r|j
        dgk    sJ | rd}t          j        t          |          5  t          |                              |d d d d f                    d d d            n# 1 swxY w Y   d}t          j        t          |          5  t          |                              |d |j        d         d	z                      d d d            d S # 1 swxY w Y   d S d S )
Nr   Fname)columnsr   z!Can only wrap 1 or 2-d array_liker1   z6obj must have the same number of elements in axis 0 asr   )r&   r   wrapr    r!   r   r5   rW   rf   r"   rg   r6   r7   r8   r.   )r   r*   bwrappedexpected_typer2   s         r   test_wrap_pandasrl      s<   JAEAA##A&&G!+;BIIMg}-----1W\111A##Av#66Gg}-----3W\V3333A##Ax#88Gg}-----3W\V3333$.>BLLBJMA##AaaagJ//Gg}-----4W_Q/14444A##AaaagJ#AAGg}-----8W_8888 83]:U333 	4 	4!!!!AAAtTM"2333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 I]:U333 	8 	8!!!!$5agajAo$5"6777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	88 8s$   ".HH #H 9J

JJc                     t          dd          } d| _        t          dd          }t          |                               |d          }d}|j        |k    sJ t          dd          } d	 t	          | j        d                   D             | _        t          dd          }t          |                               |d          }d
 | j        D             }t          |j                  |k    sJ d S )Nr   TappleFappendedappendapple_appendedr   c                 2    g | ]}d t          |          z   S )apple_)str.0is     r   
<listcomp>z+test_wrap_pandas_append.<locals>.<listcomp>   s#    >>>qCFF">>>r   c                     g | ]}|d z   S 	_appendedrb   rw   cs     r   ry   z+test_wrap_pandas_append.<locals>.<listcomp>   s    333AK333r   r&   rf   r   rh   ranger.   rg   listr*   ri   rj   expecteds       r   test_wrap_pandas_appendr      s    DAAFEAA##Aj#99GH<8####DA>>E!'!*,=,=>>>AIEAA##Aj#99G33333H  H,,,,,,r   c                     t          dd          } d| _        t          dd          }t          |                               |d          }d}|j        |k    sJ t          dd          } d	 t	          | j        d                   D             | _        t          dd          }t          |                               |d          }d
 | j        D             }t          |j                  |k    sJ d S )Nr   TrE   Fro   rp   
7_appendedr   c                     g | ]}|S rb   rb   rv   s     r   ry   z6test_wrap_pandas_append_non_string.<locals>.<listcomp>   s    ...q...r   c                     g | ]}| d S r{   rb   r}   s     r   ry   z6test_wrap_pandas_append_non_string.<locals>.<listcomp>   s    333A1333r   r   r   s       r   "test_wrap_pandas_append_non_stringr      s    DAAFEAA##Aj#99GH<8####DA..E!'!*--...AIEAA##Aj#99G33333H  H,,,,,,r   c                       e Zd ZdS )
CustomDictN)r]   r^   r_   rb   r   r   r   r     s        Dr   r   c                     | j         S r   r   r   s    r   	dict_typer     r   r   c                     | 
 |             n| }t          |dd          }t          |t          |                    sJ d S )NvalueToptional)r   rW   r4   )r   valr%   s      r   test_optional_dict_liker   
  sL    ".))+++IC
C4
0
0
0Cc499%%%%%%%r   c                     d} t          j        t          |           5  t          g dd           d d d            n# 1 swxY w Y   t          j        t          |           5  t          dhdd           d d d            n# 1 swxY w Y   t          j        t          |           5  t          ddd           d d d            d S # 1 swxY w Y   d S )Nz5value must be a dict or dict_like \(i.e., a Mapping\)r1   r   Tr   r*   )r6   r7   	TypeErrorr   r1   s    r   test_optional_dict_like_errorr     s   DE	y	.	.	. . ."g----. . . . . . . . . . . . . . .	y	.	.	. 1 13%400001 1 1 1 1 1 1 1 1 1 1 1 1 1 1	y	.	.	. / /#w..../ / / / / / / / / / / / / / / / / /s3   =AA#BB
B)C		CCc                     t          dd          } | dk    sJ t          ddd          } | dk    sJ t          j        t          d          5  t          dd           d d d            n# 1 swxY w Y   t          j        t          d          5  t          dd           d d d            n# 1 swxY w Y   t          j        t          d	          5  t          d
dd           d d d            d S # 1 swxY w Y   d S )Nrn   r   rn   bananacherryoptionsvalue must be a stringr1   r      4z1value must be one of: 'apple', 'banana', 'cherry'date)r
   r6   r7   r   r8   r%   s    r   test_stringr     s   
gw
'
'C'>>>>
gw0M
N
N
NC'>>>>	y(@	A	A	A    Aw                             	y(@	A	A	A # #D'"""# # # # # # # # # # # # # # #	D
 
 
 L L 	FG-JKKKK	L L L L L L L L L L L L L L L L L Ls6   A++A/2A/B..B25B2C44C8;C8c                     t          dd          } | dk    sJ t          ddd          } | dk    sJ t          d dd          } | J t          d ddd          } | J t          j        t          d	          5  t          d
dd           d d d            n# 1 swxY w Y   t          j        t          d	          5  t          ddd           d d d            d S # 1 swxY w Y   d S )Nrn   r   r   r   Tr   )r   r   r   r1   r   r   )r
   r6   r7   r   r   s    r   test_optional_stringr   ,  s   
gw
'
'C'>>>>
gw0M
N
N
NC'>>>>
dGd
3
3
3C;;;
g.K  C ;;;	y(@	A	A	A / /Aw..../ / / / / / / / / / / / / / /	y(@	A	A	A 2 2D'D11112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2s$   ;BB!B C  C$'C$g      ?g?333333?y333333?        c                     | j         S r   r   r   s    r   floatingr   A  r   r   r   y333333?      ?z3.2c                     | j         S r   r   r   s    r   not_floatingr   F  r   r   c                    t          t          | d          t                    sJ t          t          | dd          t                    sJ t          d dd          J t          | t          t          j        t          t          j        f          r<t          t          | dd          t                    sJ t          d ddd          J d S d S )Nr   Tr   strictr   r   )rW   r   floatintr   integerinexact)r   s    r   test_float_liker   K  s    j:66>>>>>j:EEEuMMMMMdJ666>>>(S"*eRZ@AA P*Xz$GGGOOOOO$
T$GGGOOOP POOr   c                     t          j        t                    5  t          | d           d d d            d S # 1 swxY w Y   d S )Nr   )r6   r7   r   r   )r   s    r   test_not_float_liker   T  s    	y	!	! - -<,,,- - - - - - - - - - - - - - - - - -   8<<g      @g      @c                     | j         S r   r   r   s    r   r   r   Y  r   r   g	@y      @       @yffffff@        rn   y      ?        c                     | j         S r   r   r   s    r   not_integerr   ^  s     =r   c                    t          t          | d          t                    sJ t          t          | dd          t                    sJ t          d dd          J t          | t          t          j        f          r<t          t          | dd          t                    sJ t          d ddd          J d S d S )Nr   Tr   r   r   r   )rW   r	   r   r   r   )r   s    r   test_int_liker   m  s    hw	22C88888hw	DAAA3GGGGGD*t444<<<'C,-- N(7IdCCCSIIIIIj4EEEMMMN NMMr   c                     t          j        t                    5  t          | d           d d d            d S # 1 swxY w Y   d S )Nr   )r6   r7   r   r	   )r   s    r   test_not_int_liker   v  s    	y	!	! ) )i((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )r   )TFr   r   r*    c                     | j         S r   r   r   s    r   booleanr   {  r   r   c                 |   t          t          | d          t                    sJ t          d dd          J t          | t                    r)t          t          | dd          t                    sJ d S t          j        t
                    5  t          | dd           d d d            d S # 1 swxY w Y   d S )Nr   Tr   r   )rW   r   boolr6   r7   r   )r   s    r   test_bool_liker     s   i33T:::::T9t444<<<'4   7)GYtDDDdKKKKKKK]9%% 	7 	7gy6666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   B11B58B5c                      t          j        t                    5  t          t	          j        ddg          t                     d d d            d S # 1 swxY w Y   d S )NT)r6   r7   r   r   r   arrayr   rb   r   r   test_not_bool_liker     s    	y	!	! 3 3"(D$<(('2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s   *AAA)0collectionsr   numpyr   pandasr    r6   statsmodels.tools.validationr   r   r   r   r   r	   r
   'statsmodels.tools.validation.validationr   fixturer   r&   r(   rd   rl   r   r   dictr   r   r   r   r   r   rR   r   r   r   r   r   r   r   complextimedelta64r   r   r   r   r   r   rb   r   r   <module>r      s   # # # # # #                           C B B B B B e}%%%  &%  ) ) ) ) ) ) ) )D" " "$!8 !8 !8H- - - - - -"	 	 	 	 	 	 	 	 k:t<===  >=& & &/ / /L L L$2 2 2* S*"*S//828SE??HMNNN  ON XtUDABBB  CBP P P- - -
 Q

33%ABBB  CB 
3q
 
 
 
 
N N N) ) )
 555666  767 7 73 3 3 3 3r   