
    Egg;                     d    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dS )    N)union_categoricals)CategoricalCategoricalIndexSeriesc                   B   e Zd Ze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                            deeeg          d                         Zd Zd Zd Zd Zd Ze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#d,S )-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        ||           d S )N)r   r   tmassert_categorical_equal)selfr   r   combinedr   resultexpecteds          a/var/www/sysmax/venv/lib/python3.11/site-packages/pandas/tests/reshape/test_union_categoricals.pytest_union_categoricalz,TestUnionCategoricals.test_union_categorical   s\    > $SSQ%8%8##k!nn:M:M$NOOx((
#FH55555    c                     t          g d          }t          g d          }t          ||g          }t          g dg d          }t          j        ||           d S )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   sv    (())#QG,,***7U7U7U
 
 
 	#FH55555r"   c                     t          g dd          }t          g dd          }t          ||g          }t          g dd          }t          j        ||           d S )Nr   Tordered)r   r   r   r   r   r   r,   r-   s        r    #test_union_categorical_ordered_truez9TestUnionCategoricals.test_union_categorical_ordered_true=   sq    T222d333#QG,,555tDDD
#FH55555r"   c                     t          g d          }t          g d          }d}t          j        t          |          5  t	          ||g           d d d            d S # 1 swxY w Y   d S )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   s    $$##4]9C000 	( 	(2w'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s    AA#&A#c                     d}t          j        t          |          5  t          g            d d d            d S # 1 swxY w Y   d S )NzNo Categoricals to unionr6   )r8   r9   
ValueErrorr   )r   r;   s     r    test_union_categorical_emptyz2TestUnionCategoricals.test_union_categorical_emptyL   s    (]:S111 	# 	#r"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   ;??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        ||           d S )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   s    !Q((+q!RVn*E*EF
 
 1aArv677
#C--- #s$$k3RV2D&E&EF
 
 3S#rv677
#C---\**BL,F,FO\22BL4N4NO +d"3"3[5F5F!GHH4K\**\**\**
 
 
 	#C--- !BHbfbf%5VDDDEESEbhuF.K.K.KLLL
 
 26263/00
#C--- "&"&)**K8H,I,IJ
 
 26262626:;;
#C-----r"   val1c                    |r9|dgk    r2|                     t          j                            d                     t	          t          g           t          |          g          }t          |          }t          j        ||           d S )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      	T##,, 1 12Q R RSSS +b//;s3C3C!DE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        ||           d S )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   s    ,,,???!Q26*|||DDD "b**1aAq!Q7LLLQQQ
#C-----r"   c                     t          g dg d          }t          g dg d          }t          ||g          }t          g dg d          }t          j        ||           d S )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   s}    ___EEE___EEE "b**888___UUU
#C-----r"   c                     t          g dg d          }t          g dg d          }t          ||g          }t          g dg d          }t          j        ||           d S )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   s    ___EEE___EEE#RH--***
 
 
 	#FH55555r"   c                 (   t          g dd          }t          g dd          }d}t          j        t          |          5  t	          ||g           d d d            n# 1 swxY w Y   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            d S # 1 swxY w Y   d S )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   s.   D111E2224]9C000 	) 	)Bx(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) !"b**,,,d;;;
#C---!Q26*D999!QIIItDDD "b**1aBFAq14@@@
#C---D111yyy$GGGN]9C000 	) 	)Bx(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s$   A""A&)A&(FFFc                 R   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            n# 1 swxY w Y   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            n# 1 swxY w Y   t	          j        t          |          5  t          ||g           d d d            d S # 1 swxY w Y   d S )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   s)   D111E222 "b===,,,--
#C---4]9C000 	= 	=Bxe<<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= !"b===,,,--
#C--- "b>>>,,,DQQQ
#C---!Q26*D999!QIIItDDD "b===1aBFAq122
#C---D111yyy$GGG "b===,,,--
#C--- "bdSSS,,,CCC
#C---D111D111#RH4@@@11122
#FH555N]9C000 	= 	=Bxe<<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= ]9C000 	) 	)Bx(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s6   =BB!$B!7KKK=LL #L 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            d S # 1 swxY w Y   d S )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CC***7U7U7U
 
 
 	#FH555 #s@@@#s@@@#RHdCCC333PPP
#FH555#s@@@#s@@@#RHdCCC333PPP
#FH555 #s@@@#s@@@#RHdCCC333PPP
#FH555#rv''"&#''#RHdCCCRVRVS9sCjQQQ
#FH555"&"""&""#RHdCCC/00
#FH555____#RHdCCCr??
#FH555#sNNN#sNNNI]9C000 	? 	?Bx>>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   =MM"%M"c                     t          g d          }t          g d          }t          ||gd          }t          g dg d          }t          j        ||           d S )Nr$   r(   Frw   r)   r*   r,   rf   s        r    "test_union_categoricals_sort_falsez8TestUnionCategoricals.test_union_categoricals_sort_false#  s{    ))))#RHeDDD***7U7U7U
 
 
 	#FH55555r"   c                     t          ddgg d          }t          ddgg d          }t          ||gd          }t          g dg d          }t          j        ||           d S )	Nr   r   re   r*   r   Frw   rx   r,   rf   s        r    +test_union_categoricals_sort_false_fastpathzATestUnionCategoricals.test_union_categoricals_sort_false_fastpath-      #s@@@#s@@@#RHeDDD333PPP
#FH55555r"   c                     t          ddgg d          }t          ddgg d          }t          ||gd          }t          g dg d          }t          j        ||           d S )	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        ||           d S )Nr%   r   Frw   r*   r]   rf   s        r    *test_union_categoricals_sort_false_one_nanz@TestUnionCategoricals.test_union_categoricals_sort_false_one_nan=  sz    #rv''"&#''#RHeDDDRVRVS9sCjQQQ
#FH55555r"   c                    t          t          j        g          }t          t          j        g          }t          ||gd          }t          t          j        t          j        g          }t	          j        ||           d S NFrw   r]   rf   s        r    +test_union_categoricals_sort_false_only_nanzATestUnionCategoricals.test_union_categoricals_sort_false_only_nanD  si    "&"""&""#RHeDDD/00
#FH55555r"   c                     t          g           }t          g           }t          ||gd          }t          g           }t          j        ||           d S r   r,   rf   s        r    (test_union_categoricals_sort_false_emptyz>TestUnionCategoricals.test_union_categoricals_sort_false_emptyK  sR    ____#RHeDDDr??
#FH5555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        ||           d S )
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  s    #sNNN#sNNN#RHeDDD   ___d
 
 
 	#FH5555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            d S # 1 swxY w Y   d S )
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[  sV   #s$$S#Jj111#RH--33344
#FH555b!!#RH--
#FH555BZZ#RH--
#FH555=]9C000 	6 	6OOO4555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s   #DDD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       [T%[[$$u++ttH~~6YY			#5#5#56[[+++'='='=>c263'bfc"c263RVS9 lL99lL99lL99 lL\JJJlL\JJJlL\JJJ  l;;l;;l;;'	
 8 [U[2BF$KLL6 6 ML9 :66 6 66 6 6( ( (# # #
*. *. *.X [UR#K00. . 10.. . .. . .6 6 6) ) )42) 2) 2)h4? 4? 4?l6 6 66 6 66 6 66 6 66 6 66 6 6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 8 8 8 8 8             
      ^6 ^6 ^6 ^6 ^6 ^6 ^6 ^6 ^6 ^6r"   