
    JEfg;                     \    d dl Zd dlZd dlmZ d dlZd dlmZmZm	Z	 d dl
mZ  G d d      Zy)    N)union_categoricals)CategoricalCategoricalIndexSeriesc                   n   e Zd Zej                  j                  d ed       ed       ed      fg dg dg dfg dg d	g d
fddej                  dgdej                  dgddej                  ddej                  dgf e	j                  dd       e	j                  dd       e	j                  dd      f e	j                  ddd       e	j                  ddd       e	j                  ddd      f e	j                  dd       e	j                  dd       e	j                  dd      fg      ej                  j                  deeeg      d               Zd Zd Zd Zd Zd Zej                  j                  dg dgg      d        Zd Zd Zd  Zd! Zd" Zd# Zd$ Zd% Zd& Zd' Zd( Z d) Z!d* Z"d+ Z#y,)-TestUnionCategoricalsza, b, combinedabcabdabcabd)r         r         )r   r   r   r   r   r   r   333333?r   )r   333333@r   )r   r   r   r   r   r   bacz
2014-01-01z
2014-01-05z
2014-01-06z
2014-01-07z
US/Central)tzboxc                     t         |t        |             |t        |            g      }t        |      }t        j                  ||       y )N)r   r   tmassert_categorical_equal)selfr   r   combinedr   resultexpecteds          e/var/www/VTS_Report/venv/lib/python3.12/site-packages/pandas/tests/reshape/test_union_categoricals.pytest_union_categoricalz,TestUnionCategoricals.test_union_categorical   s?    > $SQ%8#k!n:M$NOx(
##FH5    c                     t        g d      }t        g d      }t        ||g      }t        g dg d      }t        j                  ||       y )Nxyzr   r   r   r%   r&   r'   r   r   r   
categoriesr   r   r   r   r   ss2r   r   s        r    )test_union_categorical_ordered_appearancez?TestUnionCategoricals.test_union_categorical_ordered_appearance3   sF    ()#QG,*7U
 	##FH5r"   c                     t        g dd      }t        g dd      }t        ||g      }t        g dd      }t        j                  ||       y )Nr   Tordered)r   r   r   r   r   r   r,   r-   s        r    #test_union_categorical_ordered_truez9TestUnionCategoricals.test_union_categorical_ordered_true=   sE    T2d3#QG,5tD
##FH5r"   c                     t        g d      }t        g d      }d}t        j                  t        |      5  t	        ||g       d d d        y # 1 sw Y   y xY w)Nr   r   z$dtype of categories must be the samematch)r   pytestraises	TypeErrorr   )r   r.   r/   msgs       r    "test_union_categorical_match_typesz8TestUnionCategoricals.test_union_categorical_match_typesD   sJ    $#4]]9C0 	(2w'	( 	( 	(s   AAc                 ~    d}t        j                  t        |      5  t        g        d d d        y # 1 sw Y   y xY w)NzNo Categoricals to unionr6   )r8   r9   
ValueErrorr   )r   r;   s     r    test_union_categorical_emptyz2TestUnionCategoricals.test_union_categorical_emptyL   s2    (]]:S1 	#r"	# 	# 	#s   3<c           
         t        t        ddt        j                  g      t        ddt        j                  g      g      }t        ddt        j                  ddt        j                  g      }t	        j
                  ||       t        t        ddg      t        ddt        j                  g      g      }t        ddddt        j                  g      }t	        j
                  ||       t        j                  d      t        j                  d      t        j                  g}t        j                  t        j                  d      t        j                  d      g}t        t        |      t        |      g      }t        ||z   t        j                  d      t        j                  d      t        j                  d      g	      }t	        j
                  ||       t        t        t        j                  t        j                  t        j                  gt        
            t        dgt        j                  dgt        
      	      g      }t        t        j                  t        j                  dg      }t	        j
                  ||       t        t        t        j                  t        j                  g      t        t        j                  t        j                  g      g      }t        t        j                  t        j                  t        j                  t        j                  g      }t	        j
                  ||       y )Nr   r   r   ABz
2011-01-01z
2011-03-01z
2011-02-01r*   dtypeX)r   r   npnanr   r   pd	TimestampNaTarrayobjectIndex)r   resexpval1val2s        r    test_union_categoricals_nanz1TestUnionCategoricals.test_union_categoricals_nanQ   sB    !Q(+q!RVVn*EF
 1aArvv67
##C- #s$k3RVV2D&EF
 3S#rvv67
##C-\*BLL,FO\2BLL4NO +d"3[5F!GH4K\*\*\*
 	##C- !BHHbffbff%5VDESEbhhuF.KL
 2662663/0
##C- "&&"&&)*K8H,IJ
 266266266266:;
##C-r"   val1c                     |r4|dgk(  r.|j                  t        j                  j                  d             t	        t        g       t        |      g      }t        |      }t        j                  ||       y )NrT   zobject and strings dont match)applymarkerr8   markxfailr   r   r   r   )r   rS   requestusing_infer_stringrN   rO   s         r    test_union_categoricals_emptyz3TestUnionCategoricals.test_union_categoricals_empty}   s_     ##, 1 12Q RS +b/;s3C!DE#
##C-r"   c           
          t        g dg d      }t        dddt        j                  gg d      }t        ||g      }t        dddddddt        j                  gg d      }t	        j
                  ||       y )N)r   r   r   r   r*   r   r   r   r   r   rF   rG   r   r   r   r   c1c2rN   rO   s        r    $test_union_categorical_same_categoryz:TestUnionCategoricals.test_union_categorical_same_category   sf    ,?!Q266*|D "b*1aAq!Q7LQ
##C-r"   c                     t        g dg d      }t        g dg d      }t        ||g      }t        g dg d      }t        j                  ||       y )N)r'   r'   r'   r$   r*   )r%   r%   r%   )r'   r'   r'   r%   r%   r%   r,   r^   s        r    (test_union_categorical_same_category_strz>TestUnionCategoricals.test_union_categorical_same_category_str   sE    _E_E "b*8_U
##C-r"   c                     t        g dg d      }t        g dg d      }t        ||g      }t        g dg d      }t        j                  ||       y )Nr(   r*   r   r   r   )r   r   r   r   r   r   r,   r   r_   r`   r   r   s        r    6test_union_categorical_same_categories_different_orderzLTestUnionCategoricals.test_union_categorical_same_categories_different_order   sI    _E_E#RH-*
 	##FH5r"   c                    t        g dd      }t        g dd      }d}t        j                  t        |      5  t	        ||g       d d d        t	        ||g      }t        g dd      }t        j                  ||       t        dd	d
t        j                  gd      }t        d
d	gg dd      }t	        ||g      }t        dd	d
t        j                  d
d	gd      }t        j                  ||       t        g dd      }t        g dg dd      }d}t        j                  t        |      5  t	        ||g       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r   r   Tr2   F$Categorical.ordered must be the samer6   r   r   r   r   r   r   r   r   r   r+   r3   r   r   r   >to union ordered Categoricals, all categories must be the same)	r   r8   r9   r:   r   r   r   rF   rG   )r   r_   r`   r;   rN   rO   s         r    test_union_categoricals_orderedz5TestUnionCategoricals.test_union_categoricals_ordered   s4   D1E24]]9C0 	)Bx(	) !"b*,d;
##C-!Q266*D9!QItD "b*1aBFFAq14@
##C-D1y$GN]]9C0 	)Bx(	) 	)%	) 	)$	) 	)s   E7EEE$c                    t        g dd      }t        g dd      }t        ||gd      }t        g d      }t        j                  ||       d}t	        j
                  t        |      5  t        ||gd       d d d        t        ||gd      }t        g d      }t        j                  ||       t        ||gd      }t        g dg dd	      }t        j                  ||       t        d
ddt        j                  gd      }t        ddgg dd	      }t        ||gd      }t        d
ddt        j                  ddg      }t        j                  ||       t        g dd      }t        g dg dd	      }t        ||gd      }t        g d      }t        j                  ||       t        ||gdd      }t        g dg d      }t        j                  ||       t        g dd      }t        g dd      }t        ||gd      }t        g d      }t        j                  ||       d}t	        j
                  t        |      5  t        ||gd       d d d        t	        j
                  t        |      5  t        ||g       d d d        y # 1 sw Y   )xY w# 1 sw Y   HxY w# 1 sw Y   y xY w)Nri   Tr2   F)ignore_orderrk   rj   r6   rl   r   r   r   rm   )rq   sort_categoriesr*   )r         )r   r   r   r   rs   rt   rn   )	r   r   r   r   r8   r9   r:   rF   rG   )r   r_   r`   rN   rO   r;   r   r   s           r    $test_union_categoricals_ignore_orderz:TestUnionCategoricals.test_union_categoricals_ignore_order   sb   D1E2 "b=,-
##C-4]]9C0 	=Bxe<	= !"b=,-
##C- "b>,DQ
##C-!Q266*D9!QItD "b=1aBFFAq12
##C-D1y$G "b=,-
##C- "bdS,C
##C-D1D1#RH4@12
##FH5N]]9C0 	=Bxe<	= ]]9C0 	)Bx(	) 	)O	= 	=H	= 	=	) 	)s$   .J%J2J>%J/2J;>Kc                 "   t        g d      }t        g d      }t        ||gd      }t        g dg d      }t        j                  ||       t        dd	gg d
      }t        d	dgg d
      }t        ||gd      }t        g dg d      }t        j                  ||       t        dd	gg d      }t        d	dgg d      }t        ||gd      }t        g dg d      }t        j                  ||       t        dd	gg d      }t        d	dgg d      }t        ||gd      }t        g dg d      }t        j                  ||       t        dt        j
                  g      }t        t        j
                  d	g      }t        ||gd      }t        dt        j
                  t        j
                  d	gd	dg      }t        j                  ||       t        t        j
                  g      }t        t        j
                  g      }t        ||gd      }t        t        j
                  t        j
                  g      }t        j                  ||       t        g       }t        g       }t        ||gd      }t        g       }t        j                  ||       t        d	dgg d
d      }t        ddgg d
d      }d}t        j                  t        |      5  t        ||gd       d d d        y # 1 sw Y   y xY w)Nr$   r(   Trr   r)   )r   r   r   r%   r&   r'   r*   r   r   re   r   r   r   r   r   )r   r   r   r%   rl   z9Cannot use sort_categories=True with ordered Categoricalsr6   )	r   r   r   r   rF   rG   r8   r9   r:   r   r_   r`   r   r   r;   s         r    test_union_categoricals_sortz2TestUnionCategoricals.test_union_categoricals_sort   s   ))#RHdC*7U
 	##FH5 #s@#s@#RHdC3P
##FH5#s@#s@#RHdC3P
##FH5 #s@#s@#RHdC3P
##FH5#rvv'"&&#'#RHdCRVVRVVS9sCjQ
##FH5"&&""&&"#RHdC/0
##FH5__#RHdCr?
##FH5#sN#sNI]]9C0 	?Bx>	? 	? 	?s   ,LLc                     t        g d      }t        g d      }t        ||gd      }t        g dg d      }t        j                  ||       y )Nr$   r(   Frw   r)   r*   r,   rf   s        r    "test_union_categoricals_sort_falsez8TestUnionCategoricals.test_union_categoricals_sort_false#  sH    ))#RHeD*7U
 	##FH5r"   c                     t        ddgg d      }t        ddgg d      }t        ||gd      }t        g dg d      }t        j                  ||       y )	Nr   r   re   r*   r   Frw   rx   r,   rf   s        r    +test_union_categoricals_sort_false_fastpathzATestUnionCategoricals.test_union_categoricals_sort_false_fastpath-  O    #s@#s@#RHeD3P
##FH5r"   c                     t        ddgg d      }t        ddgg d      }t        ||gd      }t        g dg d      }t        j                  ||       y )	Nr   r   r(   r*   r   Frw   rx   r,   rf   s        r    -test_union_categoricals_sort_false_skipresortzCTestUnionCategoricals.test_union_categoricals_sort_false_skipresort5  r   r"   c                    t        dt        j                  g      }t        t        j                  dg      }t        ||gd      }t        dt        j                  t        j                  dgddg      }t	        j
                  ||       y )Nr%   r   Frw   r*   r]   rf   s        r    *test_union_categoricals_sort_false_one_nanz@TestUnionCategoricals.test_union_categoricals_sort_false_one_nan=  sg    #rvv'"&&#'#RHeDRVVRVVS9sCjQ
##FH5r"   c                    t        t        j                  g      }t        t        j                  g      }t        ||gd      }t        t        j                  t        j                  g      }t	        j
                  ||       y NFrw   r]   rf   s        r    +test_union_categoricals_sort_false_only_nanzATestUnionCategoricals.test_union_categoricals_sort_false_only_nanD  sY    "&&""&&"#RHeD/0
##FH5r"   c                     t        g       }t        g       }t        ||gd      }t        g       }t        j                  ||       y r   r,   rf   s        r    (test_union_categoricals_sort_false_emptyz>TestUnionCategoricals.test_union_categoricals_sort_false_emptyK  s=    __#RHeDr?
##FH5r"   c                     t        ddgg dd      }t        ddgg dd      }t        ||gd      }t        g d	g dd      }t        j                  ||       y )
Nr   r   re   Trl   r   Frw   )r   r   r   r   r,   rf   s        r    /test_union_categoricals_sort_false_ordered_truezETestUnionCategoricals.test_union_categoricals_sort_false_ordered_trueR  sY    #sN#sN#RHeD _d
 	##FH5r"   c                    t        ddg      }t        ddgd      }t        ||g      }t        g d      }t        j                  ||       t        |      }t        ||g      }t        j                  ||       t        |      }t        ||g      }t        j                  ||       d}t        j                  t        |      5  t        |g d	g       d d d        y # 1 sw Y   y xY w)
Nr   r   r   categoryrC   rx   z-all components to combine must be Categoricalr6   r(   )	r   r   r   r   r   r   r8   r9   r:   ry   s         r    test_union_categorical_unwrapz3TestUnionCategoricals.test_union_categorical_unwrap[  s    #s$S#Jj1#RH-34
##FH5b!#RH-
##FH5BZ#RH-
##FH5=]]9C0 	6O45	6 	6 	6s   CC(N)$__name__
__module____qualname__r8   rW   parametrizelistrF   rG   rH   
date_rangeperiod_ranger   r   r   r!   r0   r4   r<   r?   rR   r[   ra   rc   rg   ro   ru   rz   r|   r~   r   r   r   r   r   r    r"   r    r   r      s   [[%[$u+tH~6	#56+'=>c2663'bffc"c2663RVVS9 lL9lL9lL9 lL\JlL\JlL\J  l;l;l;'	
8 [[U[2BF$KL6 M9:666(#
*.X [[UR#K0. 1...6)42)h4?l66666666r"   r   )numpyrF   r8   pandas.core.dtypes.concatr   pandasrH   r   r   r   pandas._testing_testingr   r   r   r"   r    <module>r      s,      8  
 ^6 ^6r"   