
    Owgt#                     p    d dl m Z  d dlZd dlZd dlZd dlmZmZ d dlm	Z
 d dlmZ defdZ G d d      Zy)	    )datetimeN)IndexSeries)	safe_sortreturnc                 0    t        |       t        |      k(  S )zO
    Checks if the set of unique elements of arr1 and arr2 are equivalent.
    )	frozenset)arr1arr2s     b/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/indexes/base_class/test_setops.pyequal_contentsr      s     T?io--    c                      e Zd Zej                  j                  dg d      d        Zd Zd Zej                  j                  de	j                  eeg      d        Zd Zd	 Zd
 Zd Zej                  j                  de	j                  eeg      d        Zd Zd Zd Zej                  j                  d eddg      dgf eg d      ddgfg      d        Zd Zd Zej                  j                  dd e	j                  g ddefdg      dfd e	j                  g ddefdg      d fd! e	j                  g d"defdg      d fg      d#        Zej                  j                  d$d%d&gg g      ej                  j                  d'd&d%gg g      ej                  j                  d(g d)      d*                      Zej                  j                  d+d,d-dggd.g d/gg      d0        Zy )1TestIndexSetOpsmethod)unionintersection
differencesymmetric_differencec                     t        ddg      }t        ddg      }t        j                  t        d      5   t	        ||      |d       d d d         t	        ||      |d       y # 1 sw Y   xY w)	NabczThe 'sort' keyword only takesmatch   sortT)r   pytestraises
ValueErrorgetattr)selfr   idx1idx2s       r   test_setops_sort_validationz+TestIndexSetOps.test_setops_sort_validation   sl     c3Z c3Z ]]:-LM 	0!GD&!$Q/	0 	fd.		0 	0s   A((A1c                    t        g dt              }|j                  |dd        }|dd  }t        j                  ||       |j                  |dd  d d d         }t        j                  ||       |j                  |dd  d       }|}t        j                  ||j                         |j                  |dd  d       }t        j                  ||       |j                  |dd  d d d   d       }t        j                  ||j                         |j                  |dd  d d d   d       }t        j                  ||       y )N)   r      dtyper(   r   )	r   objectr   tmassert_index_equal_unionassert_numpy_array_equalvaluesr   )r#   idxresultexpecteds       r   !test_setops_preserve_object_dtypez1TestIndexSetOps.test_setops_preserve_object_dtype$   s.   IV,!!#ab'*qr7
fh/ !!#ab'$B$-0
fh/CG$/
##FHOO<3qr7.
fh/ CGDbDM5
##FHOO<3qr74R4=t4
fh/r   c                     t        g d      }|dd  }|d d }|j                  |      }t        g d      }t        j                  ||       y )Nr   r   r(   r   r   r   r)      )r   r(   r   r   r   r   )r   r   r.   r/   r#   indexfirstsecondr4   r5   s         r   test_union_basezTestIndexSetOps.test_union_base>   sL    ./ab	rV$12
fh/r   klassc                     t        g d      }|dd  }|d d }|j                   ||j                              }t        ||      sJ y )Nr8   r)   r9   )r   r   r2   r   )r#   r?   r;   r<   r=   r4   s         r   test_union_different_type_basez.TestIndexSetOps.test_union_different_type_baseH   sL     ./ab	rU6==12fe,,,r   c                     t        dt        j                  d      g      }t        j                  t
              5  |j                  |d d       }d d d        t        j                  |       t        j                  t
              5  |j                  |d d d       }d d d        t        j                  ||       |j                  |d d d      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   XxY w)Nr(   2000r   F)r   pd	Timestampr.   assert_produces_warningRuntimeWarningr   r/   )r#   r3   r4   s      r   "test_union_sort_other_incomparablez2TestIndexSetOps.test_union_sort_other_incomparableS   s    QV,-.''7 	(YYs2Aw'F	( 	fc* ''7 	3YYs2AwTY2F	3
fc* 3r7/
fc*	( 	(	3 	3s   C(C4(C14C=c                     t        dt        j                  d      g      }t        j                  t
        d      5  |j                  |d d d       d d d        y # 1 sw Y   y xY w)Nr(   rC   z.*r   Tr   )r   rD   rE   r   r    	TypeErrorr   r#   r3   s     r   'test_union_sort_other_incomparable_truez7TestIndexSetOps.test_union_sort_other_incomparable_truee   sS    QV,-.]]9D1 	*IIc"1gDI)	* 	* 	*s   AA%c                     t        g d      }t        g d      }t        j                  |j                  |d      |       y )Nr   r   r   )r   r   r   Tr   r   r.   r/   r   )r#   r3   sorted_s      r   !test_intersection_equal_sort_truez1TestIndexSetOps.test_intersection_equal_sort_truej   s6    O$(
c..s.>Hr   c                     t        g d      }|d d }|d d }|t        g d      nt        g d      }|j                  ||      }t        j                  ||       y )Nr8   r9   r)   )r   r(   r   r   r   r(   r   r   r   r.   r/   )r#   r   r;   r<   r=   r5   r4   s          r   test_intersection_basez&TestIndexSetOps.test_intersection_baseo   s]    ./bq	r)-5%5;M##F#6
fh/r   c                     t        g d      }|d d }|d d }|j                   ||j                        |      }t        ||      sJ y )Nr8   r9   r)   r   )r   r   r2   r   )r#   r?   r   r;   r<   r=   r4   s          r   %test_intersection_different_type_basez5TestIndexSetOps.test_intersection_different_type_basey   sS     ./bq	r##E&--$8t#Dff---r   c                     t        g d      j                  ddg      }t        ddg      }t        j                  ||       y )N)r   r   r   r   r   rT   )r#   r4   r5   s      r   test_intersection_nosortz(TestIndexSetOps.test_intersection_nosort   s9    '44c3Z@#s$
fh/r   c                     t        g d      }t        j                  |j                  |d      |       t        j                  |j                  |d       |       y )NrN   Fr   rO   rK   s     r   test_intersection_equal_sortz,TestIndexSetOps.test_intersection_equal_sort   sL    O$
c..s.?E
c..s.>Dr   c                     t        ddd      t        ddd      g}t        |t              }t        dgt              }|j                  ||      }t	        |      dk(  sJ y )	Ni  r   	      r*   aar   r   )r   r   r-   r   len)r#   r   dt_datesi1i2r4   s         r   test_intersection_str_datesz+TestIndexSetOps.test_intersection_str_dates   s\    T1a((4B*?@86*D6($/6{ar   zindex2,expected_arrBD)re   rf   Arg   c                     t        g d      }t        |      }|j                  ||      }||j                         }t        j                  ||       y )N)rg   re   rg   Cr   )r   r   sort_valuesr.   r/   )r#   index2expected_arrr   index1r5   r4   s          r   *test_intersection_non_monotonic_non_uniquez:TestIndexSetOps.test_intersection_non_monotonic_non_unique   sQ     +,&$$V$$7<++-H
fh/r   c                     t        g d      }|d d }|dd  }|j                  ||      }t        g d      }|t        t        |            }t        j                  ||       y )Nr8      r)   rS   )r   r   r   r.   r/   )r#   r   r;   r<   r=   r4   r5   s          r   test_difference_basez$TestIndexSetOps.test_difference_base   sc    ./bq	qr!!&$/%<Yx01H
fh/r   c                     t        g d      }|d d }|dd  }|j                  |      }t        g d      }t        j                  ||       y )Nr8   rp   r)   )r   r(   r   r   r   )r   r   r.   r/   r:   s         r   test_symmetric_differencez)TestIndexSetOps.test_symmetric_difference   sN    ./bq	qr++F3,-
fh/r   zmethod,expected,sortr   r(   rg   r   rg   r(   re   r   re   numletS1r*   F)ru   rw   rv   rx   Nr   )ru   rw   r(   ri   rv   rx   r   ri   c                 8   t        t        j                  g ddt        fdg            }t        t        j                  g ddt        fdg            } t	        ||      ||      }|j
                  dk(  sJ t        |      }t        j                  ||       y )Nrt   ry   rz   r*   )ru   rv   rw   rx   r}   r~   r   r(   )r   nparrayintr"   ndimr.   r/   )r#   r   r5   r   rm   rk   r4   s          r   test_tuple_union_bugz$TestIndexSetOps.test_tuple_union_bug   s    < HH8s|]3
 HHLs|]3
 )(d;{{a?
fh/r   
first_listr   r   second_listz&first_name, second_name, expected_name))rg   re   N)Nre   N)rg   NNc                    t        ||      }t        ||      }|j                  ||      }	t        |      j                  |      }
|It        |      dkD  r;t        |      dkD  r-t        t	        |
      |      }t        j                  |	|       y t        |
|      }t        j                  |	j                         |j                                y )N)namer   r   )r   r   setr`   sortedr.   r/   rj   )r#   r   r   
first_namesecond_nameexpected_namer   r<   r=   r   valsr5   s               r   test_union_name_preservationz,TestIndexSetOps.test_union_name_preservation   s     jz2{5F.:$$[1<C
Oa/C4Dq4HVD\>H!!%2T6H!!%"3"3"5x7K7K7MNr   zdiff_type, expectedr   r(   r   )r(   r   re   ri   c                     t        g d      }t        g d      } t        ||      |      }t        |      }t        j                  ||       y )N)r   r(   rg   re   )r   r   rg   ri   )r   r"   r.   r/   )r#   	diff_typer5   r$   r%   r4   s         r   test_difference_object_typez+TestIndexSetOps.test_difference_object_type   sF     %&%&)y)$/?
fh/r   )__name__
__module____qualname__r   markparametrizer&   r6   r>   r   r   r   listrA   rH   rL   rQ   rU   rW   rY   r[   rd   r   rn   rq   rs   r   r   r   r    r   r   r   r      sl   [[Q//040 [[Wrxx&>?- @-+$*
I
0 [[Wrxx&>?. @.0
E
  [[
c

cU	#eO&<sCj%IJ0	0
00 [[ <!3<7  <!3<7  P!3<7 #	
:0;:0( [[\S#J+;<[[]c3Z,<=[[0@O	 > =O  [[
C	!$:<L#MN0	0r   r   )r   numpyr   r   pandasrD   r   r   pandas._testing_testingr.   pandas.core.algorithmsr   boolr   r   r   r   r   <module>r      s6         ,.$ .t0 t0r   