
    Egt#                     x    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dS )	    )datetimeN)IndexSeries)	safe_sortreturnc                 B    t          |           t          |          k    S )zO
    Checks if the set of unique elements of arr1 and arr2 are equivalent.
    )	frozenset)arr1arr2s     `/var/www/sysmax/venv/lib/python3.11/site-packages/pandas/tests/indexes/base_class/test_setops.pyequal_contentsr      s     T??ioo--    c                      e Zd Zej                            dg d          d             Zd Zd Zej                            de	j
        eeg          d             Zd Zd	 Zd
 Zd Zej                            de	j
        eeg          d             Zd Zd Zd Ze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                            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                            d$d%d&gg g          ej                            d'd&d%gg g          ej                            d(g d)          d*                                     Zej                            d+d,d-dggd.g d/gg          d0             Zd S )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            n# 1 swxY w Y    t	          ||          |d           d S )	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   s     c3Z  c3Z  ]:-LMMM 	0 	0!GD&!!$Q////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	fd......s   A&&A*-A*c                     t          g dt                    }|                    |dd                    }|dd          }t          j        ||           |                    |dd          d d d                   }t          j        ||           |                    |dd          d           }|}t          j        ||j                   |                    |dd          d           }t          j        ||           |                    |dd          d d d         d           }t          j        ||j                   |                    |dd          d d d         d           }t          j        ||           d S )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$   sr   IIIV,,,!!#abb'**qrr7
fh/// !!#abb'$$B$-00
fh///CG$//
#FHO<<<3qrr7..
fh/// CGDDbDM55
#FHO<<<3qrr744R4=t44
fh/////r   c                     t          g d          }|dd          }|d d         }|                    |          }t          g d          }t          j        ||           d S )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>   sn    ...//abb	rrV$$11122
fh/////r   klassc                     t          g d          }|dd          }|d d         }|                     ||j                            }t          ||          sJ d S )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   sk     ...//abb	rrUU6=1122fe,,,,,,,r   c                 D   t          dt          j        d          g          }t          j        t
                    5  |                    |d d                   }d d d            n# 1 swxY w Y   t          j        ||           t          j        t
                    5  |                    |d d         d           }d d d            n# 1 swxY w Y   t          j        ||           |                    |d d         d          }t          j        ||           d S )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7 	( 	(YYs2A2w''F	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	fc*** '77 	3 	3YYs2A2wTY22F	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3
fc*** 3rr7//
fc*****s#   A''A+.A+  CCCc                     t          dt          j        d          g          }t          j        t
          d          5  |                    |d d         d           d d d            d S # 1 swxY w Y   d S )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   s    QV,,-..]9D111 	* 	*IIc"1"gDI)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s    A,,A03A0c                     t          g d          }t          g d          }t          j        |                    |d          |           d S )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   sP    OOO$$((
c..s.>>HHHHHr   c                     t          g d          }|d d         }|d d         }|t          g d          nt          g d          }|                    ||          }t          j        ||           d S )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    ...//bqb	rr)-5%%%5;M;M##F#66
fh/////r   c                     t          g d          }|d d         }|d d         }|                     ||j                  |          }t          ||          sJ d S )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   sr     ...//bqb	rr##EE&-$8$8t#DDff-------r   c                     t          g d                              ddg          }t          ddg          }t          j        ||           d S )N)r   r   r   r   r   rT   )r#   r4   r5   s      r   test_intersection_nosortz(TestIndexSetOps.test_intersection_nosort   sO    ''44c3Z@@#s$$
fh/////r   c                     t          g d          }t          j        |                    |d          |           t          j        |                    |d           |           d S )NrN   Fr   rO   rK   s     r   test_intersection_equal_sortz,TestIndexSetOps.test_intersection_equal_sort   se    OOO$$
c..s.??EEE
c..s.>>DDDDDr   c                     t          ddd          t          ddd          g}t          |t                    }t          dgt                    }|                    ||          }t	          |          dk    sJ d S )	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          |          }|                    ||          }||                                }t          j        ||           d S )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   sl     +++,,&&$$V$$77<++--H
fh/////r   c                    t          g d          }|d d         }|dd          }|                    ||          }t          g d          }|t          t          |                    }t          j        ||           d S )Nr8      r)   rS   )r   r   r   r.   r/   )r#   r   r;   r<   r=   r4   r5   s          r   test_difference_basez$TestIndexSetOps.test_difference_base   s    ...//bqb	qrr!!&$//%%<Yx0011H
fh/////r   c                     t          g d          }|d d         }|dd          }|                    |          }t          g d          }t          j        ||           d S )Nr8   rp   r)   )r   r(   r   r   r   )r   r   r.   r/   r:   s         r   test_symmetric_differencez)TestIndexSetOps.test_symmetric_difference   sp    ...//bqb	qrr++F3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                 V   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        ||           d S )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    < H888s|]3  
 
 HLL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          ||          }|                    ||          }	t          |                              |          }
|[t          |          dk    rHt          |          dk    r5t          t	          |
          |          }t          j        |	|           d S t          |
|          }t          j        |	                                |                                           d S )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22{555F..:$$[11<C
OOa//C4D4Dq4H4HVD\\>>>H!%22222T666H!%"3"3"5"5x7K7K7M7MNNNNNr   zdiff_type, expectedr   r(   r   )r(   r   re   ri   c                     t          g d          }t          g d          } t          ||          |          }t          |          }t          j        ||           d S )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   si     %%%&&%%%&&)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      s       [QQQ / / /0 0 040 0 0 [Wrx&>??- - @?-+ + +$* * *
I I I
0 0 0 [Wrx&>??. . @?.0 0 0
E E E
      [
%c

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