
    Owg                     N   d Z ddlm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mZmZmZmZmZmZmZmZ ddlmZ ddlmZmZ defd	Z ej8                  ej:                  g d
z         d        Zd Zd Z ejB                  jE                  d e ejF                  d      ejH                         ed      f e ejF                  d      ejJ                         e ejF                  d      ejH                        f e ejF                  d      ejJ                         ed      f e ejF                  d      ejJ                         e ejF                  d      ejL                        fg      d        Z'ejB                  jE                  dg d      ejB                  jE                  dddg      d               Z(ejB                  jE                  dg dddgg      d        Z) G d d      Z*ejB                  jW                  d      ejB                  jW                  d       ejB                  jE                  d!g d"      d#                      Z,d$ Z-d% Z.d& Z/d' Z0d( Z1ejB                  jE                  d)d*ejd                  g      d+        Z3d, Z4d- Z5d. Z6 G d/ d0      Z7y)1zX
The tests in this package are to ensure the proper resultant dtypes of
set operations.
    )datetimeN)lib)find_common_type)	CategoricalDtypeCategoricalIndexDatetimeTZDtypeIndex
MultiIndexPeriodDtype
RangeIndexSeries	Timestamp)is_signed_integer_dtypepandas_dtypereturnc                 0    t        |       t        |      k(  S )zO
    Checks if the set of unique elements of arr1 and arr2 are equivalent.
    )	frozenset)arr1arr2s     W/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/indexes/test_setops.pyequal_contentsr   !   s     T?io--    )objectcategorydatetime64[ns]ztimedelta64[ns])paramsc                     | j                   S )z
    Dtypes that can be given to an Index with small positive integers.

    This means that for any dtype `x` in the params list, `Index([1, 2, 3], dtype=x)` is
    valid and gives the correct Index (sub-)class.
    )param)requests    r   'any_dtype_for_small_pos_integer_indexesr    (   s      ==r   c                     | j                         }| j                         }|j                  |      j                  |j                  k(  sJ y N)sort_valuesuniondtype)indexidx1idx2s      r   test_union_same_typesr)   ;   sA     DD::d!!TZZ///r   c                    | }|}|j                   s>|j                   s2|j                  j                  dk(  r|j                  j                  dk(  sJ|j                   su|j                   si|j                  j                  dk(  rP|j                  j                  dk(  r7t        j                  j                  dt        d      }|j                  |       t        |j                  |j                  g      }d }d}t        |      rt        |      sn |j                  j                  dk(  r t        j                  |j                  d      r9|j                  j                  dk(  r't        j                  |j                  d      st        }nt        |j                  t              rt        |j                  t              s4t        |j                  t              rYt        |j                  t              r?t         }d	}t        j                  j                  d
t"        d      }|j                  |       t$        j&                  |j                  |j                  fv }	t)        |j                        }
t)        |j                        }|j+                         }|j+                         }t-        j.                  ||      5  |j1                  |      }|j1                  |      }d d d        |	rM|
s|rIj                  t%        j                  d      k(  sJ j                  t%        j                  d      k(  sJ y j                  |k(  sJ j                  |k(  sJ y # 1 sw Y   {xY w)NibzGH#44000 True==1F)reasonraisesstrictz'<' not supported betweenciufczPeriodDtype\[B\] is deprecatedz"Warning not produced on all buildsmatchO)	is_uniquer%   kindpytestmarkxfail
ValueErrorapplymarkerr   lenr   is_np_dtypeRuntimeWarning
isinstancer   r   FutureWarningAssertionErrornpuint64r   r#   tmassert_produces_warningr$   )
index_flatindex_flat2r   r'   r(   r8   common_dtypewarnmsg
any_uint64idx1_signedidx2_signedres1res2s                 r   test_union_different_typesrP   C   s    DD NNJJOOs"JJOOs"NNJJOOs"JJOOs" {{  %j ! 
 	D!#TZZ$<=LD
%Ct9CI
**//S
 #//$**f*M

3

F(K 4::{+
4::GW0X4::{+
4::GW0X/{{  7! ! 

 	D!tzz4::66J)$**5K)$**5K DD		#	#D	4  zz$zz$  {kzzRXXc]***zzRXXc]***zz\)))zz\)))   s   6#MMz	idx1,idx2   r%   c                     | j                  |      }|j                  |       }|j                  | j                  |j                  fv sJ |j                  | j                  |j                  fv sJ y r"   )r$   r%   )r'   r(   rN   rO   s       r   "test_compatible_inconsistent_pairsrT      s^     ::dD::dD::$**djj1111::$**djj1111r   zleft, right, expected))int64rU   rU   )rU   rC   r   )rU   float64rV   )rC   rV   rV   )rC   rC   rC   )rV   rV   rV   )r   rU   r   )r   rC   r   )r   rV   r   )datetime64[ns, CET]rU   r   )rW   rC   r   )rW   rV   r   )	Period[D]rU   r   )rX   rC   r   )rX   rV   r   names)foorZ   rZ   )rZ   barNc                 *   t        |       } t        |      }t        g | |d         }t        g ||d         }|j                  |      }|j                  |k(  sJ |j                  |d   k(  sJ |j                  |      }|j                  |d   k(  sJ y )Nr   )r%   name      )r   r	   r$   r%   r]   intersection)leftrightexpectedrY   ar,   results          r   test_union_dtypesrf      s    , DEb58,AbE!H-AWWQZF<<8###;;%(""" ^^AF;;%("""r   valuesr^   r_   r_      ri   c                     t        |       }t        ddg      }|j                  |      }t        dg      }t        j                  ||       y )Nri   )r	   r`   rD   assert_index_equal)rg   rd   r,   re   rc   s        r   test_intersection_duplicatesrl      sC     	fAq!fA^^AFaSzH&(+r   c                      e Zd Zej                  j                  dddg      ej                  j                  dg d      d               Zej                  j                  d      d        Zej                  j                  d	      ej                  j                  d      d
               Z	ej                  j                  d      ej                  j                  d	      d               Z
ej                  j                  d      ej                  j                  d	      d               Zej                  j                  dg d      d        Zej                  j                  dg d      d        Zej                  j                  dg d      d        Zej                  j                  dg d      d        Zej                  j                  d      d        Zd Zd Zd Zy)
TestSetOpscaseg      ?xxxmethodr`   r$   
differencesymmetric_differencec                     d}t        j                  t        |      5   t        ||      |       d d d        y # 1 sw Y   y xY w)Nz!Input must be Index or array-liker2   )r7   r.   	TypeErrorgetattr)selfro   rq   r&   rJ   s        r   test_set_ops_error_casesz#TestSetOps.test_set_ops_error_cases   s=     2]]9C0 	)"GE6"4(	) 	) 	)s	   :A3ignore:PeriodDtype\[B\] is deprecated:FutureWarningc                    t        |t              r+t        j                  dt	        |      j
                          |d d j                         }|d d j                         }|j                  |      }t        j                  ||       t        |j                  t              ry |j                         |j                         |j                         g}|D ]!  }|j                  |      }t        ||      r!J  t        |t               r:d}t        j"                  t$        |      5  |j                  g d       d d d        y y # 1 sw Y   y xY w)NNot relevant for rQ   ri   .other must be a MultiIndex or a list of tuplesr2   r^   r_   ri   )r?   r   r7   skiptype__name__uniquer`   rD   rk   r%   r   to_numpy	to_seriesto_listr   r
   r.   rv   )	rx   r&   firstsecond	intersectcasesro   re   rJ   s	            r   test_intersection_basez!TestSetOps.test_intersection_base   s'   e-.KK+DK,@,@+ABCbq	  "r!!#&&v.	
i0ekk?3  "F$4$4$68HI 	2D''-F!&&111	2 eZ(BCy4 .""9-. . ). .s   &EEEignore:Falling back on a non-pyarrow:pandas.errors.PerformanceWarningc                 N   |j                         }|dd  }|d d }|}|j                  |      }t        j                  |j	                         |j	                                t        |j                  t              ry |j                         |j                         |j                         g}|D ]!  }|j                  |      }t        ||      r!J  t        |t              r:d}	t        j                  t        |	      5  |j                  g d       d d d        y y # 1 sw Y   y xY w)Nri   rQ   r}   r2   r~   )r   r$   rD   rk   r#   r?   r%   r   r   r   r   r   r
   r7   r.   rv   )
rx   r&   r   r   
everythingr$   r   ro   re   rJ   s
             r   test_union_basezTestSetOps.test_union_base   s	   
 ab	r
F#
e//1:3I3I3KLekk?3  "F$4$4$68HI 	6D[[&F!&*555	6 eZ(BCy4 'I&' ' )' 's   =DD$c                 H   |dd  }|d d }|j                   dk(  r$t        |      j                  t        |            }nt        |t              rg }n|dd  }|j                  ||      }t        ||      sJ |j                         |j                         |j                         g}|D ]"  }|j                  ||      }t        ||      r"J  t        |t              r;d}	t        j                  t        |	      5  |j                  g d|       d d d        y y # 1 sw Y   y xY w)Nr_      booleanr}   r2   r~   )inferred_typesetrs   r?   r   r   r   r   r   r
   r7   r.   rv   )
rx   sortr&   r   r   answerre   r   ro   rJ   s
             r   test_difference_basezTestSetOps.test_difference_base  s#   
 ab	r)+ Z**3v;7F/0F12YF!!&$/ff--- "F$4$4$68HI 	2D%%dD1F!&&111	2 eZ(BCy4 2  D12 2 )2 2s   9DD!c                    t        |t              r+t        j                  dt	        |      j
                          t        |      dk  rt        j                  d       |d   |dd  v s
|d   |d d v rt        j                  d       |dd  }|d d }|ddg   }|j                  |      }t        j                  |j                         |j                                |j                         |j                         |j                         g}|D ]!  }|j                  |      }t        ||      r!J  t        |t              r:d}t        j                   t"        |	      5  |j                  g d
       d d d        y y # 1 sw Y   y xY w)Nr|   r_   zToo few values for testr   r^   z+Index values no not satisfy test condition.r}   r2   r~   )r?   r   r7   r   r   r   r<   rt   rD   rk   r#   r   r   r   r   r
   r.   rv   )	rx   r&   r   r   r   re   r   ro   rJ   s	            r   test_symmetric_differencez$TestSetOps.test_symmetric_difference-  sm   
 e-.KK+DK,@,@+ABCu:>KK128uQRy E"Is$; KKEFab	s2w++F3
f002F4F4F4HI "F$4$4$68HI 	2D//5F!&&111	2 eZ(BCy4 6**956 6 )6 6s   E<<Fzfname, sname, expected_name)Ar   r   r   BN)r   NNNr   N)NNNc                 l   |j                   s|j                         }n|}|j                         j                  |      }|j                         j                  |      }|j	                  |      }|j                         j                  |      }	t        j                  ||	       |j                         j                  |      }|j                  |      j                  |      }|j	                  |      }|j                         j                  |      }	t        j                  ||	       |j                  |      j                  |      }|j                         j                  |      }|j	                  |      }|j                         j                  |      }	t        j                  ||	       |j                  |      j                  |      }|j                  |      j                  |      }|j	                  |      }|j                  |      j                  |      }	t        j                  ||	       y r"   )r5   r   copy	set_namesr$   rD   rk   drop
rx   rF   fnamesnameexpected_namer&   r   r   r$   rc   s
             r   test_corner_unionzTestSetOps.test_corner_unionL  s    ##%%'EE 

&&u-''.F#::<))-8
eX. 

&&u-E",,U3F#::<))-8
eX. 

5!++E2''.F#::<))-8
eX. 

5!++E2E",,U3F#::e$..}=
eX.r   c                 P   |j                   s|j                         }n|}|j                         j                  |      }|dd  j                  |      }|j	                  |      j                         }|j                  |      j                         }	t        j                  ||	       y Nr^   )r5   r   r   r   r$   r#   rD   rk   r   s
             r   test_union_unequalzTestSetOps.test_union_unequal{  s     ##%%'EE 

&&u-qr$$U+F#//1??=1==?
eX.r   c                 p   |j                   s|j                         }n|}|j                         j                  |      }|j                         j                  |      }|j	                  |      }|j                         j                  |      }	t        j                  ||	       |j                         j                  |      }|j                  |      j                  |      }|j	                  |      }|j                  |      j                  |      }	t        j                  ||	       |j                  |      j                  |      }|j                         j                  |      }|j	                  |      }|j                  |      j                  |      }	t        j                  ||	       |j                  |      j                  |      }|j                  |      j                  |      }|j	                  |      }|j                  |      j                  |      }	t        j                  ||	       y r"   )r5   r   r   r   r`   rD   rk   r   
rx   rF   r   r   r   r&   r   r   r   rc   s
             r   test_corner_intersectz TestSetOps.test_corner_intersect  s    ##%%'EE 

&&u-''.&&v.	::<))-8
i2 

&&u-E",,U3&&v.	::e$..}=
i2 

5!++E2''.&&v.	::e$..}=
i2 

5!++E2E",,U3&&v.	::e$..}=
i2r   c                 V   |j                   s|j                         }n|}|j                         j                  |      }|dd  j                  |      }|j	                  |      j                         }|dd  j                  |      j                         }	t        j                  ||	       y r   )r5   r   r   r   r`   r#   rD   rk   r   s
             r   test_intersect_unequalz!TestSetOps.test_intersect_unequal  s     ##%%'EE 

&&u-qr$$U+&&v.::<	9&&}5AAC
i2r   c                    t        |t              r.|j                  t        t	        |j
                                    }n|j                  d      }t        j                  |      }|j                  |      }|j                  |j                  k(  sJ |j                  |d d       }|j                  |j                  k(  sJ |d d j                  |      }|j                  |j                  k(  sJ y )NrZ   r   )
r?   r
   renamelistrangenlevelsrB   asarrayr`   r]   )rx   r&   otherre   s       r   .test_intersection_name_retention_with_namelessz9TestSetOps.test_intersection_name_retention_with_nameless  s    eZ(LLeEMM&:!;<ELL'E

5!##E*{{ejj((( ##E"1I.{{ejj((( r''.{{ejj(((r   c                     |j                   st        j                  d       |j                  ||      }|d d }t	        j
                  ||d       y )Nz&Not relevant since index is not uniquer   r   Texact)r5   r7   r   rs   rD   rk   )rx   r&   r   re   rc   s        r   $test_difference_preserves_type_emptyz/TestSetOps.test_difference_preserves_type_empty  sJ     KK@A!!%d!3!9
fhd;r   c                 Z   t        |t              r|D cg c]  }|g|j                  z   }}|j                  |d         }|j                  |d         }|j	                  |      sJ |j                  |      }|d d j                  |d         }t        j                  ||       y c c}w )Nr   r^   r_   )r?   r
   r   r   equalsrs   rD   rk   )rx   r&   rY   xr   re   rc   s          r   %test_difference_name_retention_equalsz0TestSetOps.test_difference_name_retention_equals  s    eZ(278QaS5==(8E8U1X&U1X&||E"""!!%(!9##E!H-
fh/ 9s   B(c                     |j                   st        j                  d       |j                  |d d       }|j	                  ||      }t        j                  ||d       y )Nz(Not relevant because index is not uniquer   r   Tr   )r5   r7   r   r`   rs   rD   rk   )rx   r&   r   interdiffs        r   (test_intersection_difference_match_emptyz3TestSetOps.test_intersection_difference_match_empty  sU    
 KKBC""5!9-D1
eT6r   N)r   
__module____qualname__r7   r8   parametrizery   filterwarningsr   r   r   r   r   r   r   r   r   r   r   r    r   r   rn   rn      s   [[Vc5\2[[Q) 3) [[ VW. X.2 [[O [[ VW' X'2 [[ VW[[O2 X22 [[ VW[[O6 X66 [[%	
	#/	#/J [[%	
	/	/ [[%	
	"3	"3H [[%	
	3	3 [[ VW) X)&<
0	7r   rn   rz   r   rq   rr   c                 ^   | }|j                  d      }t        |t              rdnd} t        ||      ||      } t        ||      ||      }t	        j
                  |||        t        ||      |d d |      } t        ||      |d d |      }t	        j
                  |||       y )Nr   equivTr   r   rQ   )astyper?   r   rw   rD   rk   )rF   r   rq   r&   r   r   re   rc   s           r   test_setop_with_categoricalr     s     ELL$E!%4G$E#WUF#E5F%wuf%e$7H&(%8#WUF#E"1ID9F%wuf%eBQid;H&(%8r   c                     | j                   rt        j                  d       | }|g d   }|j                  |      j	                  |j                  |            sJ |j                  |      j
                  sJ y )NzNot relevant for empty Indexr   r   r^   r_   )emptyr7   r   r`   r   r5   )r&   idxidx_non_uniques      r   (test_intersection_duplicates_all_indexesr   $  si    {{23
C&NN+22>3N3Ns3STTTN+5555r   c                 <   | }t        g d|      }t        g d|      }t        g d|      }t        |t              rt        g d      }|j                  |      }t	        j
                  ||       |j                  |d      }t	        j
                  ||       y )Nrh   rR   )ri   ri   r   )r^   r_   r_   ri   ri   r   Fr   r	   r?   r   r$   rD   rk   r    r%   rd   r,   rc   re   s         r   0test_union_duplicate_index_subsets_of_each_otherr   1  s     4El%(Aiu%A'u5H!%&+,WWQZF&(+WWQUW#F&(+r   c                     | }t        g d|      }t        ddg|      }t        g d|      }|j                  |      }t        j                  ||       |j                  |      }t        j                  ||       y )N)r^   r   r   rR   r   r^   r   r   r^   r	   r$   rD   rk   r   s         r   1test_union_with_duplicate_index_and_non_monotonicr   B  sk     4Eiu%Aq!fE"AYe,HWWQZF&(+WWQZF&(+r   c                      t        g d      } t        g d      }t        g d      }| j                  |d      }t        j                  ||       y )Nrh   )10r   )r^   r_   r_   ri   r   r   r   Fr   r   )rd   r,   rc   re   s       r   +test_union_duplicate_index_different_dtypesr   R  sC    lAoA01HWWQUW#F&(+r   c                      t        g d      } t        g d      }| j                  |      }t        g d      }t        j                  ||       y )Nr   r   r   )rd   r,   re   rc   s       r   (test_union_same_value_duplicated_in_bothr   [  s=    iAlAWWQZF\"H&(+r   dupr^   c                    t        t        j                  dddg      }t        t        j                  | ddg      }|j                  |d      }t        t        j                  | dddg      }t	        j
                  ||       y )Nr^   r_   Fr   g      ?       @)r	   rB   nanr$   rD   rk   )r   rd   r,   re   rc   s        r   test_union_nan_in_bothr   d  sm     	rvvq!Q ArvvsAq!"AWWQUW#Fbffc3S12H&(+r   c                      t        ddd      } t        ddd      }| j                  |d      }t        g d      }t        j                  ||       y )	Nr^   d      2   ri   Tr   )r^   r      
                        "   %   (   +   .   1   7   =   C   I   O   U   [   a   )r   r$   r	   rD   rk   )r'   r(   re   rc   s       r   test_union_rangeindex_sort_truer  n  sQ    aa DaQDZZ4Z(F	
H: &(+r   c                 8   | }t        g d|      }t        g d|      }t        g d|      }t        |t              rt        g d      }|j                  |      }t	        j
                  ||       |j                  |      }t	        j
                  ||       y )N)r^   r   r_   rR   r   r   r   r   s         r   <test_union_with_duplicate_index_not_subset_and_non_monotonicr    s|     4Eiu%Aiu%A\/H!%&&WWQZF&(+WWQZF&(+r   c                     t        ddt        j                  g      } | j                  j                  j
                  dk(  sJ t        ddg      }|j                  |       }t        ddt        j                  gt        j                        }t        j                  ||       | j                  |      }t        j                  ||       y )Nr^   r_   r+   rR   )r   rB   r   
categoriesr%   r6   r	   r$   rV   rD   rk   )cir   re   rc   s       r   #test_union_int_categorical_with_nanr    s    	1a.	)B==##s***
A-CYYr]FaBFF^2::6H&(+XXc]F&(+r   c                   D   e Zd Zd Zej
                  j                  ddgd      d        Zej
                  j                  d eg dd	      df eg dd
	      df eg d      dfg      d        Z	ej
                  j                  ddgd      ej
                  j                  dg d      d               Z
d Zej
                  j                  ddgd      d        Zej
                  j                  dej                  eeg      ej
                  j                  ddgd      d               Zej
                  j                  ddgd      d        Zej
                  j                  ddgd      ej
                  j                  dddg      d               Zd Zd Zej
                  j                  ddgd      d        Zej
                  j                  ddgd      d        Zej
                  j                  dddg      d         Zej
                  j                  dddg      d!        Zd" Zej
                  j                  d# ed$d%ej6                  g       eg d&      f ed$d%g       eej6                  d'd(d)g      fg      d*        Zd+ Zd, Zd- Zy.)/TestSetOpsUnsortedc                     t        ddd      t        ddd      g}t        |t              }t        dgt              }|j                  |      }t        g t              }t	        j
                  ||       y )Ni  r_   	   r   rR   aa)r   r	   r   r`   rD   rk   )rx   dt_datesindex1index2re   rc   s         r   test_intersect_str_datesz+TestSetOpsUnsorted.test_intersect_str_dates  sd    T1a((4B*?@xv.vV,$$V,6*
fh/r   r&   stringT)indirectc                 
   |d d }|d d }|j                  ||      }|dv r3t        j                  |j                         |j                                nt        j                  ||       |j                  ||      }||u sJ y )N   r   r   NF)r`   rD   rk   r#   )rx   r&   r   r   r   r   r   s          r   test_intersectionz$TestSetOpsUnsorted.test_intersection  s    cr
s&&vD&9	= !!)"7"7"96;M;M;OP!!)V4 ""5t"4~~r   zindex2,keeps_name)ri   r   rQ   r   r   r]   r   Fc                     t        g dd      }t        g d      }|j                  ||      }|rd|_        |j                  |j                  k(  sJ t        j                  ||       y )Nr^   r_   ri   r   rQ   r&   r  ri   r   rQ   )r	   r`   r]   rD   rk   )rx   r  
keeps_namer   r  rc   re   s          r   #test_intersection_name_preservationz6TestSetOpsUnsorted.test_intersection_name_preservation  s\     W5#$$VT2#HM{{hmm+++
fh/r   z$first_name,second_name,expected_name)r   r   r   c                 |    |dd }|d d }||_         ||_         |j                  ||      }|j                   |k(  sJ y )NrQ   r  r   r   )r]   r`   )	rx   r&   
first_namesecond_namer   r   r   r   r   s	            r   $test_intersection_name_preservation2z7TestSetOpsUnsorted.test_intersection_name_preservation2  sO     as
!&&vD&9	~~...r   c                 (   t        ddgd      }t        ddgd      }t        dd	gd
      }|j                  |j                  ||      |      }|j                  ||      j                  ||      }t        j                  ||       t        ddgd      }t        g d      }t        g d      }	|j                  |j                  |	|      |      }|j                  ||      j                  |	|      }t        j                  ||       y )Nr^   r_   i1r  rQ   r   i2ri   r   i3r   j1j2j3r   )
rx   r   r#  r$  r%  r$   rc   r&  r'  r(  s
             r   test_chained_unionz%TestSetOpsUnsorted.test_chained_union  s    Aq6%Aq6%Aq6%"40t<88BT8*00$0?
eX.Aq6%2D!2D!"40t<88BT8*00$0?
eX.r   c                     |dd }|d d }|d d }|j                  ||      }|dv r3t        j                  |j                         |j                                y t        j                  ||       y NrQ   r  r   r   r  )r$   rD   rk   r#   )rx   r&   r   r   r   r   r$   s          r   
test_unionzTestSetOpsUnsorted.test_union   so    as3BZ
F.= !!%"3"3"5z7M7M7OP!!%4r   klassc                    |dd }|d d }|d d } ||j                         }|j                  ||      }|dv r3t        j                  |j	                         |j	                                y t        j                  ||       y r+  )rg   r$   rD   rk   r#   )	rx   r&   r-  r   r   r   r   ro   re   s	            r   test_union_from_iterablesz,TestSetOpsUnsorted.test_union_from_iterables  s     as3BZ
V]]#T-= !!&"4"4"6
8N8N8PQ!!&*5r   c                 
   |dd }|j                  ||      }||u | u sJ |j                  t        g |j                        |      }||u | u sJ t        g |j                        j                  ||      }||u | u sJ y )NrQ   r  r   rR   )r$   r	   r%   )rx   r&   r   r   r$   s        r   test_union_identityz&TestSetOpsUnsorted.test_union_identity  s    aE-H--- E"EKK8tDH---b,225t2DH---r   zsecond_name,expected)NN)r]   r]   c                 P   |dd }|d d }|dd }d|_         ||_         |j                  ||      }|du rt        j                  ||       n9||_         t        j                  |j	                         |j	                                ||j                   J y |j                   |k(  sJ y )NrQ   r  r   r]   r   T)r]   rs   rD   rk   r#   )	rx   r&   r   rc   r   r   r   r   re   s	            r   !test_difference_name_preservationz4TestSetOpsUnsorted.test_difference_name_preservation+  s     asr"
!!!&t!44<!!&&1%FK!!&"4"4"68J8J8LM;;&&&;;(***r   c                     |j                         }|dd }d|_        |j                  g |      }|dd j                         }d|_        t	        j
                  ||       y )NrQ   r  r]   )r   r]   rs   r   rD   rk   )rx   r&   r   r   re   rc   s         r   test_difference_empty_argz,TestSetOpsUnsorted.test_difference_empty_argA  s\    

a
!!"d+2;%%'
fh/r   c                     t        ddg      }t        dg      }|j                  |      }t        dg      }t        j                  ||       y )Nr^   T)r	   rs   rD   rk   )rx   ra   rb   re   rc   s        r   "test_difference_should_not_comparez5TestSetOpsUnsorted.test_difference_should_not_compareJ  sC    aV}tf'!:
fh/r   c                     |dd }d|_         |j                  ||      }t        |      dk(  sJ |j                   |j                   k(  sJ y )NrQ   r  r]   r   )r]   rs   r<   )rx   r&   r   r   re   s        r   test_difference_identityz+TestSetOpsUnsorted.test_difference_identityR  sN    a
!!%.6{a{{ejj(((r   c                     |dd }|d d }|j                  ||      }|dd }||j                         }t        j                  ||       y )NrQ   r  r   )rs   r#   rD   rk   )rx   r&   r   r   r   re   rc   s          r   test_difference_sortz'TestSetOpsUnsorted.test_difference_sort[  sX    as!!&$/B<<++-H
fh/r   opnamers   rt   c                    t        dt        d      dg      }t        dt        d      dg      }t        j                  ||      }t	        j
                  t              5   ||      }d d d        t        dt        d      dt        d      g      }|dk(  r|d d }t	        j                  |       t        j                  ||d      } ||      }t	        j                  ||       y # 1 sw Y   xY w)	Nri   2000r^   r_   1999rs   Fr   )r	   r   operatormethodcallerrD   rE   r>   rk   )rx   r<  rd   r,   opre   rc   s          r   test_difference_incomparablez/TestSetOpsUnsorted.test_difference_incomparableh  s    1i'+,1i'+,""61-''7 	UF	 !Yv.9V3DEF\!|H
fh/ ""6159A
fh/	 	s   	C''C0c                    t        dt        d      dg      }t        dt        d      dg      }t        j                  ||d      }d}t	        j
                  t        |	      5   ||       d d d        y # 1 sw Y   y xY w)
Nri   r>  r^   r_   r?  Tr   z<'<' not supported between instances of 'Timestamp' and 'int'r2   )r	   r   r@  rA  r7   r.   rv   )rx   r<  rd   r,   rB  rJ   s         r   !test_difference_incomparable_truez4TestSetOpsUnsorted.test_difference_incomparable_true{  sq    1i'+,1i'+,""6148L]]9C0 	qE	 	 	s   $	A66A?c                    t        j                  t        g dg d            }t        j                  ddg      }|j                  ||      }t        j                  g d      }||j	                         }t        j                  ||       y )N)rZ   r[   bazr~   )rZ   r^   r[   ri   r   ))r[   r_   )rG  ri   rH  )r
   from_tuplesziprt   r#   rD   rk   )rx   r   r  r  re   rc   s         r   test_symmetric_difference_miz/TestSetOpsUnsorted.test_symmetric_difference_mi  sx    '',A9(MN''Z(@A,,V$,?))*NO<++-H
fh/r   zindex2,expectedr   r^   )r         @        r   rL  rM  c                     t        dt        j                  ddg      }|j                  ||      }||j	                         }t        j                  ||       y )Nr^   r_   ri   r   )r	   rB   r   rt   r#   rD   rk   )rx   r  rc   r   r  re   s         r   !test_symmetric_difference_missingz4TestSetOpsUnsorted.test_symmetric_difference_missing  sS     2661a(),,V$,?<++-H
fh/r   c                 
   t        g dd      }t        j                  g d      }t        ddgd      }|j                  ||      }|dv rt	        j
                  ||       n$t	        j
                  |j                         |       |j                  dk(  sJ |j                  |d	|
      }d	|_        |dv rt	        j
                  ||       n$t	        j
                  |j                         |       |j                  d	k(  sJ y )N)r^   r_   ri   r   r  r  )r_   ri   r   rQ   r^   rQ   r   )NTnew_name)result_namer   )r	   rB   arrayrt   rD   rk   r#   r]   )rx   r   r  r  rc   re   s         r   #test_symmetric_difference_non_indexz6TestSetOpsUnsorted.test_symmetric_difference_non_index  s    |(3,'!Qh/,,V$,?<!!&(3!!&"4"4"6A{{h&&&,,VRV,W"<!!&(3!!&"4"4"6A{{j(((r   c                     t        g d|      }t        g d|      }|j                  |      }t        g d|      }t        j                  ||       y )Nr~   rR   r  r  r   )rx   any_numeric_ea_and_arrow_dtyper   r(   re   rc   s         r   test_union_ea_dtypesz'TestSetOpsUnsorted.test_union_ea_dtypes  sF    I%CDY&DE40NO
fh/r   c                     t        dg|      }t        dg|      }|j                  |      }t        ddg|      }t        j                  ||       y )Nrd   rR   r,   r   )rx   any_string_dtyper'   r(   re   rc   s         r   test_union_string_arrayz*TestSetOpsUnsorted.test_union_string_array  sO    cU"23cU"23D!#s+;<
fh/r   N) r   r   r   r  r7   r8   r   r  r	   r  r!  r)  r,  rB   rS  r   r   r/  r1  r3  r5  r7  r9  r;  rC  rE  rK  r   rO  rT  rW  rZ  r   r   r   r
  r
    s   0 [[Wxj4@ A [[?148?159?#U+	
	0	0 [[Wxj4@[[.>/	 A
//  [[Wxj4@	5 A	5 [[Wrxx&>?[[Wxj4@6 A @6 [[Wxj4@. A. [[Wxj4@[[3lDT5UV+ W A+(00 [[Wxj4@) A) [[Wxj4@
0 A
0 [[X6L'MN0 O0$ [[X6L'MN O0 [[Aq"&&>"E/$:;Aq6]E2663S"9:;	
00)&00r   r
  )8__doc__r   r@  numpyrB   r7   pandas._libsr   pandas.core.dtypes.castr   pandasr   r   r   r	   r
   r   r   r   r   pandas._testing_testingrD   pandas.api.typesr   r   boolr   fixtureALL_REAL_NUMPY_DTYPESr    r)   rP   r8   r   arangerU   rV   rC   rT   rf   rl   rn   r   r   r   r   r   r   r   r   r   r  r  r  r
  r   r   r   <module>rg     s        4
 
 
 .$ . ##0G*T 	yryy|288	,jm<	yryy|2::	.ibiil"((0ST	yryy|2::	.
1>	yryy|2::	.ibiil"))0TU	22 ( #8:N"OP# Q)*# L1a&#9:, ;,}7 }7@
 RSK M9 T9 
6,", ,, BFF,, -,",J,$,L0 L0r   