o
    5cg#                     @   s^   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 G dd dZdS )    )datetimeN)IndexSeries)	safe_sortc                
   @   s  e Zd Zejdg ddd Zdd Zdd Zejd	e	j
eegd
d Zdd Zejjdddd Zejjdddd Zdd Zejd	e	j
eegdd Zdd Zdd Zdd Zejdedd gdgfeg d!d"dgfgd#d$ Zd%d& Zd'd( Zejd)d*e	j
g d+d,efd-gd.d/fd*e	j
g d0d,efd-gd.d1fd2e	j
g d3d,efd-gd.d1fgd4d5 Zejd6d7d8gg gejd9d8d7gg gejd:g d;d<d= Zejd>d?d@dggdAg dBggdCdD Zd1S )ETestIndexSetOpsmethod)unionintersection
differencesymmetric_differencec                 C   s^   t ddg}t ddg}tjtdd t|||dd W d    d S 1 s(w   Y  d S )NabczThe 'sort' keyword only takesmatchTsort)r   pytestraises
ValueErrorgetattr)selfr   idx1idx2 r   a/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/tests/indexes/base_class/test_setops.pytest_setops_disallow_true   s
   "z)TestIndexSetOps.test_setops_disallow_truec                 C   s
  t g dtd}||dd  }|dd  }t|| ||dd  d d d }t|| |j|dd  d d}|}t||j |j|dd  d d}t|| |j|dd  d d d d d}t||j |j|dd  d d d d d}t|| d S )N)         dtyper   r   )	r   objectr	   tmassert_index_equal_unionassert_numpy_array_equalvaluesr   )r   idxresultexpectedr   r   r   !test_setops_preserve_object_dtype   s     z1TestIndexSetOps.test_setops_preserve_object_dtypec                 C   sJ   t g d}|dd  }|d d }||}t g d}t|| d S )Nr   r   r   r   r   r   r      )r   r   r   r   r   r   )r   r   r$   r%   r   indexfirstsecondr*   r+   r   r   r   test_union_base4   s   
zTestIndexSetOps.test_union_baseklassc                 C   sH   t g d}|dd  }|d d }|||j}t||s"J d S )Nr-   r   r.   )r   r   r(   r$   equalContents)r   r4   r0   r1   r2   r*   r   r   r   test_union_different_type_base>   s
   z.TestIndexSetOps.test_union_different_type_basec                 C   s   t dtdg}tt ||d d }W d    n1 s"w   Y  t|| tt |j|d d d d}W d    n1 sHw   Y  t|| |j|d d dd}t|| d S )Nr   2000r   F)r   pd	Timestampr$   assert_produces_warningRuntimeWarningr   r%   )r   r)   r*   r   r   r   "test_union_sort_other_incomparableI   s   z2TestIndexSetOps.test_union_sort_other_incomparablez(GH#25151 need to decide on True behavior)reasonc                 C   s\   t dtdg}tjtdd |j|d d dd W d    d S 1 s'w   Y  d S )Nr   r7   z.*r   Tr   )r   r8   r9   r   r   	TypeErrorr   r   r)   r   r   r   'test_union_sort_other_incomparable_true[   s   "z7TestIndexSetOps.test_union_sort_other_incomparable_truec                 C   s2   t g d}t g d}t|j|dd| d S )Nr   r   r   )r   r   r   Tr   r   r$   r%   r	   )r   r)   sorted_r   r   r   !test_intersection_equal_sort_truec   s   z1TestIndexSetOps.test_intersection_equal_sort_truec                 C   sb   t g d}|d d }|d d }|d u rt g dnt g d}|j||d}t|| d S )Nr-   r.   r   )r   r   r   r   r   r   r   r   r	   r$   r%   )r   r   r0   r1   r2   r+   r*   r   r   r   test_intersection_basej   s    z&TestIndexSetOps.test_intersection_basec                 C   sL   t g d}|d d }|d d }|j||j|d}t||s$J d S )Nr-   r.   r   r   )r   r	   r(   r$   r5   )r   r4   r   r0   r1   r2   r*   r   r   r   %test_intersection_different_type_baset   s
   z5TestIndexSetOps.test_intersection_different_type_basec                 C   s2   t g dddg}t ddg}t|| d S )N)r   r   r   r   r   rF   )r   r*   r+   r   r   r   test_intersection_nosort~   s   z(TestIndexSetOps.test_intersection_nosortc                 C   s<   t g d}t|j|dd| t|j|d d| d S )NrA   Fr   rB   r?   r   r   r   test_intersection_equal_sort   s   z,TestIndexSetOps.test_intersection_equal_sortc                 C   sT   t dddt dddg}t|td}tdgtd}|j||d}t|dks(J d S )	Ni  r   	      r    aar   r   )r   r   r#   r	   len)r   r   dt_datesi1i2r*   r   r   r   test_intersection_str_dates   s
   z+TestIndexSetOps.test_intersection_str_dateszindex2,expected_arrBD)rS   rT   ArU   c                 C   sF   t g d}t |dd}|j||d}|d u r| }t|| d S )N)rU   rS   rU   Cr#   r    r   )r   r	   sort_valuesr$   r%   )r   index2expected_arrr   index1r+   r*   r   r   r   *test_intersection_non_monotonic_non_unique   s   z:TestIndexSetOps.test_intersection_non_monotonic_non_uniquec                 C   s`   t g d}|d d }|dd  }|||}t g d}|d u r(t t|}t|| d S )Nr-      r   rE   )r   r
   r   r$   r%   )r   r   r0   r1   r2   r*   r+   r   r   r   test_difference_base   s   z$TestIndexSetOps.test_difference_basec                 C   sJ   t g d}|d d }|dd  }||}t g d}t|| d S )Nr-   r\   r   )r   r   r   r   r   )r   r   r$   r%   r/   r   r   r   test_symmetric_difference   s   
z)TestIndexSetOps.test_symmetric_differencezmethod,expected,sortr	   r   rU   r   rU   r   rS   r   rS   numleta1r    F)r`   rb   ra   rc   Nr   )r`   rb   r   rV   ra   rc   r   rV   c                 C   st   t tjg ddtfdgd}t tjg ddtfdgd}t||||d}|jdks.J t |}t|| d S )Nr_   rd   re   r    )r`   ra   rb   rc   rh   ri   r   r   )r   nparrayintr   ndimr$   r%   )r   r   r+   r   rZ   rX   r*   r   r   r   test_tuple_union_bug   s    

z$TestIndexSetOps.test_tuple_union_bug
first_listr   r   second_listz&first_name, second_name, expected_name))rU   rS   N)NrS   N)rU   NNc                 C   s   t ||d}t ||d}|j||d}	t||}
|d u r:t|dkr:t|dkr:t t|
|d}t|	| d S t |
|d}t|	| d S )N)namer   r   )r   r   setrN   sortedr$   r%   r5   )r   ro   rp   
first_namesecond_nameexpected_namer   r1   r2   r   valsr+   r   r   r   test_union_name_preservation   s   	 z,TestIndexSetOps.test_union_name_preservationzdiff_type, expectedr
   r   r   )r   r   rS   rV   c                 C   s>   t g d}t g d}t|||}t |}t|| d S )N)r   r   rU   rS   )r   r   rU   rV   )r   r   r$   r%   )r   	diff_typer+   r   r   r*   r   r   r   test_difference_object_type   s
   z+TestIndexSetOps.test_difference_object_type)__name__
__module____qualname__r   markparametrizer   r,   r3   rj   rk   r   listr6   r<   xfailr@   rD   rG   rH   rI   rJ   rR   r   r[   r]   r^   rl   rn   rx   rz   r   r   r   r   r      s    







		$
	

	
	

r   )r   numpyrj   r   pandasr8   r   r   pandas._testing_testingr$   pandas.core.algorithmsr   r   r   r   r   r   <module>   s    