o
    _~#g                     @   s  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	  m
Z ddlmZmZmZmZmZmZ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  ddl!m"Z" e#dZ$G d	d
 d
Z%G dd dZ&G dd dZ'G dd dZ(G dd dZ)G dd dZ*dS )z* test positional based indexing with iloc     )datetimeN)IndexingError)NACategoricalCategoricalDtype	DataFrameIndexIntervalNaTSeries	Timestamparrayconcat
date_rangeinterval_rangeisnato_datetime)	is_scalar)"check_indexing_smoketest_or_raiseszuonly integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indicesc                   @   sP   e Zd Zejdddg dgejdddgejdg d	d
d ZdS )TestiLockey   r      r   kindseriesframecol)labelsmixedtsfloatsemptyc                 C   s(   | | d| }t|d|td d S )N_iloc)fails)getfixturevaluer   
IndexError)selfr   r   r   requestobj r,   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/tests/indexing/test_iloc.py"test_iloc_getitem_int_and_list_int)   s   
z+TestiLoc.test_iloc_getitem_int_and_list_intN)__name__
__module____qualname__pytestmarkparametrizer.   r,   r,   r,   r-   r   (   s    r   c                   @   s  e Zd ZdZejdedededg de	ede
g dgejdejejgdd Zejd	eegd
d Zdd Zdd Zejde
dedfgejdedddggddgedfedddgedfgdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zejd(d)d*gg d+gd,d- Zd.d/ Z d0d1 Z!d2d3 Z"d4d5 Z#d6d7 Z$d8d9 Z%d:d; Z&d<d= Z'd>d? Z(d@dA Z)dBdC Z*dDdE Z+dFdG Z,ejddHgeddde
dHggejdIdJge
dJggdKdL Z-ej.dMdNdO Z/dPdQ Z0dRdS Z1dTdU Z2dVdW Z3dXdY Z4dZd[ Z5d\d] Z6d^d_ Z7d`da Z8ejdIde9e
j:gdbdc Z;ejdde<dHddedfgdgdh Z=didj Z>ejdejejgdkdl Z?dmdn Z@dodp ZAejdqee
jgdrds ZBejddgeddtgdudv ZCdwdx ZDdydz ZEd{d| ZFd}d~ ZGdd ZHdd ZIejdee
jgejdee
jgdd ZJdd ZKdd ZLeMjNdd ZOdd ZPdS )TestiLocBaseIndependentzTests Independent Of Base Classr   N   r   indexerc           	      C   s  t dtditd}tg d}|s|jjd |sJ | }|j}||||df< t d|i	t}|sBt
|d j|sBJ t|| d|jd< |d dksUJ t t
jg dtdtdd}| }||||df< t t|	ttdtdd}t|| d S )	Nr   r6   dtype)alphabetagammar<   r   r   r   r   r   )r   rangeobjectr   _mgrblocks_can_hold_elementcopyvaluesastypenpshares_memorytmassert_frame_equalr%   r   r   )	r)   r7   r   using_array_managerr   catdf	orig_valsexpectedr,   r,   r-   %test_iloc_setitem_fullcol_categorical?   s$   
  z=TestiLocBaseIndependent.test_iloc_setitem_fullcol_categoricalboxc                 C   s   t g d}||d}|tu r|j}n|jjd }|tu r-||dd  |jd d< n||dd  |jd ddf< |tj g ddd}t	|| |tu rn|re|j|usZJ t
|j|scJ d S |j|u slJ d S t
|d j|syJ d S )Nr   r   r6      i8r   r   )r6   rS   r6   rS   r8   )r   to_numpyr   rE   rA   arraysr%   rG   rI   assert_equalrH   )r)   frame_or_seriesrQ   using_copy_on_writearrr+   rE   rO   r,   r,   r-   test_iloc_setitem_ea_inplacek   s    z4TestiLocBaseIndependent.test_iloc_setitem_ea_inplacec                 C   sH   t g d}ttd|d}|jdsJ | }|jds"J d S )N)r   r   r   r6   index)r   r   r   )r   r   r?   r%   _is_scalar_accessto_frame)r)   r]   serrM   r,   r,   r-   test_is_scalar_access   s
   z-TestiLocBaseIndependent.test_is_scalar_accessc              	   C   s  t tjddtdd}d}tjt|d |jd d g df  W d    n1 s.w   Y  tjt|d |jdd	g  W d    n1 sLw   Y  tjt|d |jdd
g  W d    n1 sjw   Y  tjt|d |jdg  W d    n1 sw   Y  |d }tjt|d |jdg  W d    n1 sw   Y  tjt|d |jdg  W d    n1 sw   Y  d}tjt|d |jd	  W d    n1 sw   Y  tjt|d |jd
  W d    n1 sw   Y  tjt|d |jd	  W d    n	1 sw   Y  tjt|d |jd
  W d    n	1 s9w   Y  |jd d ddf }|jd d dd f }t	
|| |jd d ddf }|jd d d df }t	
|| |jd d dddf }|jd d d ddf }t	
|| |jd d dddf }|jd d dd df }t	
|| |jd d ddf }|jd d d df }t	
|| |jd d ddf }|jd d d df }t	
|| |jd d dddf }|jd d d df }t	
|| |jd d ddf }|jd d d df }t	
|| |jdd	 }|jdd  }t	|| |jd	d  }|jd d }t	|| |jd	d d }|jd d d }t	|| t tjddtdd}t	
|jd d ddf t |jtg |jjdd t	
|jd d ddf |jd d dgf  t	
|jdd |jdg  d}tjt|d |jg d  W d    n	1 sw   Y  d}tjt|d |jd d df  W d    d S 1 sw   Y  d S )Nr   )      ABCDEcolumnsz%positional indexers are out-of-boundsmatchr   r   r   r6   rS   rd   r      id   Aiz*single positional indexer is out-of-boundsrS   
   ir   r   i      rd   r   ABr6   r8   r]   rg      rS   rd   ru   )r   rG   randomdefault_rnglistr2   raisesr(   r%   rI   rJ   assert_series_equalstandard_normalr]   r   rg   r9   )r)   rM   msgsresultrO   dflr,   r,   r-   test_iloc_exceeds_bounds   s   .$z0TestiLocBaseIndependent.test_iloc_exceeds_boundszindex,columnsrc   re   zindex_vals,column_valsrm   D12i  r   c                 C   sn   t tjdt|t|f||d}d}tjt|d |j	||f  W d    d S 1 s0w   Y  d S )Nr   rt   z$.iloc requires numeric indexers, gotrh   )
r   rG   rw   rx   r|   lenr2   rz   r(   r%   )r)   r]   rg   
index_valscolumn_valsrM   r}   r,   r,   r-   test_iloc_non_integer_raises   s   "z4TestiLocBaseIndependent.test_iloc_non_integer_raisesc                 C   s`   t tddd}t||}tjtdd |j	d  W d    d S 1 s)w   Y  d S )Nrl   rn   zCannot index by location indexrh   a)
r   rG   arangereshaperI   get_objr2   rz   	TypeErrorr%   )r)   rX   r+   r,   r,   r-    test_iloc_getitem_invalid_scalar  s
   "z8TestiLocBaseIndependent.test_iloc_getitem_invalid_scalarc                 C   sr   t g d}| }tg dg dg ddg dd}|j|  t|| |jd d |f  t|| d S )N)r   r   r   )rl   e   f   )g   h   i   )j   k   l   rm   BCr   r   r6   r\   )rG   r   rD   r   r%   rI   assert_numpy_array_equal)r)   array_with_neg_numbers
array_copyrM   r,   r,   r-   -test_iloc_array_not_mutating_negative_indices  s   
zETestiLocBaseIndependent.test_iloc_array_not_mutating_negative_indicesc                 C   s   t g dg dd}|d }|jd }|jd }t|| |jdg }|jdg }t|| |jd }|jd }||ksAJ |jdg }|jdg }t|| tdgdgd}|jd	g }t|| d S )
N)r   r6   rd   )   rp      rm   r   rm   r   r   r\   r   )r   r%   rI   r{   rJ   r   )r)   rM   r~   rO   r   r,   r,   r-   /test_iloc_getitem_neg_int_can_reach_first_index"  s"   



zGTestiLocBaseIndependent.test_iloc_getitem_neg_int_can_reach_first_indexc                 C   s   t d dddddg}t ddddddg}t||gdd}|jd }t|s+J |jdd d f }ttjdddgg d	dd
}t|| d S )Nr   r   r   r6   rS   axisr=   r   rm   r   rm   r   )r]   name)	r   r   r%   r   r   rG   nanrI   r{   )r)   df1df2rM   r   rO   r,   r,   r-   test_iloc_getitem_dups=  s   
z.TestiLocBaseIndependent.test_iloc_getitem_dupsc                 C   s   t dddddddddd	d
dg}t ddddg}t|jdg | t ddddddddg}t|jddg | t dddd	d
dgddgd}|jddgddgf }t|| d S )Nr   r   r6   r   rl      ,        r   )r   r   r\   )r   rI   rJ   r%   r)   rM   rO   r   r,   r,   r-   test_iloc_getitem_arrayK  s   


 z/TestiLocBaseIndependent.test_iloc_getitem_arrayc                 C   s   t dddddddddd	d
dg}t ddddddddg}|jg d }t|| t dddddd	d
dgddgd}|jdd  }t|| d S )Nr   r   r6   r   rl   r   r   r   r   r   )TTFr   r\   c                 S   s   | j d dkS )Nr   r   r\   xr,   r,   r-   <lambda>n  s    z@TestiLocBaseIndependent.test_iloc_getitem_bool.<locals>.<lambda>r   r%   rI   rJ   r   r,   r,   r-   test_iloc_getitem_bool^  s   


z.TestiLocBaseIndependent.test_iloc_getitem_boolr]   TF)TFTFc                 C   sb   t g d}dt| dt| }tjt|d |j|  W d    d S 1 s*w   Y  d S )Nr   z Boolean index has wrong length: z instead of rh   )r   r   r2   rz   r(   r%   )r)   r]   r~   r}   r,   r,   r-   test_iloc_getitem_bool_diff_lenq  s
   "z7TestiLocBaseIndependent.test_iloc_getitem_bool_diff_lenc                 C   s   t dddddddddd	d
dg}t ddddddddg}|jd d }t|| t dddgdgd}|jddddf }t|| t dddddddd
dg}|jd d dd f }t|| d S )Nr   r   r6   r   rl   r   r   r   r   r   r   r\   r   )rm   r   c                 S      ddgS )Nr   r   r,   )rM   r,   r,   r-   r         zATestiLocBaseIndependent.test_iloc_getitem_slice.<locals>.<lambda>r   r   r,   r,   r-   test_iloc_getitem_slicey  s"   


z/TestiLocBaseIndependent.test_iloc_getitem_slicec                 C   s  t tjddg dd}t tjdjddddddd	d
gd}t||gdd}t	|j
d d d df | t	|j
d d dd f | t||gdd}t	|j
d d d df | t	|j
d d dd f | t||j
d d dgf gdd}t	|j
d d ddf | t||gdd}t	|j
ddd df | t	|j
dddd f | t	|j
dd d df | t	|j
dd dd f | d S )Nr   rn   rS   )rm   rm   r   r   rf   r   rn   rc   sizerm   r   r   r   rS   r6   )r   rG   rw   rx   r|   integersr   r   rI   rJ   r%   )r)   r   r   rM   expr,   r,   r-   test_iloc_getitem_slice_dups  s*    "z4TestiLocBaseIndependent.test_iloc_getitem_slice_dupsc                 C   s   t tjddtdddtdddd}d|jd	< |jd	 }|dks(J d|jd d ddf< |jd d ddf }|jd d ddf }t|| t	dg d
d}|jdd  d7  < t	g dg d
d}t
|| d S )Nr   rS   rS   r         r6   rt   r   r   r   rv   r\   r   r   r   )r   rG   rw   rx   r|   r   r%   rI   rJ   r   r{   )r)   warn_copy_on_writerM   r   rO   r~   r,   r,   r-   test_iloc_setitem  s    

z)TestiLocBaseIndependent.test_iloc_setitemc                 C   s   t g dg dg dg}|d t|d< t g dg dg dg}|d t|d< d|jddd	< t|| t g dg dg dg}|d t|d< t g d
g dg dg}|d t|d< d|jddd	< t|| d S )N)ru   crn   )r   drp   )r   er   r   )rd   rd   rd   rd   r   r   r   )ru   r   rd   )r   r   rd   )r   r   rd   )r   rF   r@   r%   rI   rJ   r)   rM   rO   r,   r,   r-   test_iloc_setitem_axis_argument  s   z7TestiLocBaseIndependent.test_iloc_setitem_axis_argumentc                 C   s   t tddg dg dd}|jddgddgf  |jddgddgf  d7  < t tg d	dg dg dd}t|| d S )
N	   r6   r6   r   rt   r   r   r   rl   )	r   r   r   r6   r   r   ru   r   r   )r   rG   r   r   r%   r   rI   rJ   r   r,   r,   r-   test_iloc_setitem_list  s   z.TestiLocBaseIndependent.test_iloc_setitem_listc                 C   sp   t g d}t g d}| }ddg|jt ddg< t|| | }ddg|jtddg< t|| d S )N)r   r   r   r6   )r   r   r6   r   r   r   r   )r   rD   r%   rI   r{   r   )r)   s_origrO   r~   r,   r,   r-   test_iloc_setitem_pandas_object  s   z7TestiLocBaseIndependent.test_iloc_setitem_pandas_objectc                 C   sf  t d dddddg}t ddddddg}t||gdd}|d}t|jd d df }|| j}|j|df |j|df< t|| t ddgddgd}d	d	g|_	|d
= t|| |jddgddgf |jddgddgf< t|| |jddgddgf j
dd|jddgddgf< |jddgddgf j
dd|jddgddgf< t|| d S )Nr   r   r   r6   rS   r   r   r>   r   rm   T)drop)r   r   fillnarG   isnanr%   r]   rI   rJ   rg   reset_index)r)   r   r   rM   rO   indsmaskr,   r,   r-   test_iloc_setitem_dups  s"   


(00z.TestiLocBaseIndependent.test_iloc_setitem_dupsc                 C   s  t ddgddggddgd}|jd d df d|jd d df< |s-t|jjdks-J tjtdd	 |jd d df d
 |jd d df< W d    n1 sQw   Y  |sbt|jjdksbJ |	 }|jddgddgf |jddgddgf< t
|| d S )Nr   r   r   r6   r   rf   f8incompatible dtyperh   g      ?)r   r%   rF   r   rA   rB   rI   assert_produces_warningFutureWarningrD   rJ   )r)   rK   rM   rO   r,   r,   r-   9test_iloc_setitem_frame_duplicate_columns_multiple_blocks  s   &&(zQTestiLocBaseIndependent.test_iloc_setitem_frame_duplicate_columns_multiple_blocksc                 C   s  t tjddtdddtdddd}|jd }|jd }t	|| |jd }|jd	 }||ks6J |jdd }|jdd
 }t
|| |jd d ddf }|jd d ddf }t
|| |jg d }|jg d }t
|| |jg dddgf }|jg dddgf }t
|| |jg dddgf }|jg dddgf }t
|| |jg dddgf }|jg dddgf }t
|| ttddtd}|j|j }|jg d }t
|| d S )Nr   r   r   rc   r   rt   rS   )r   r   r      r6   rd   )r   r   r6   )r   r   ru   r   )r   r   r6   r   )rq   r   ru   ru   )r   r   r   r6   )rq   rq   r   ru   )r]   r9   )r   rS   ru   r   )r   rG   rw   rx   r|   r?   r%   locrI   r{   rJ   r   r@   r]   )r)   rM   r   r   rO   r~   r,   r,   r-   test_iloc_getitem_frame(  sB   





z/TestiLocBaseIndependent.test_iloc_getitem_framec                 C   s  t tjddtdtdd}|jd }|jd }||ks"J |jd d ddf }|jd d d	gf }t	|| |jd
 }|jd }||ksMJ d}t
jt|d |jd  W d    n1 sfw   Y  d}t
jt|d |jd  W d    d S 1 sw   Y  d S )Nr   r   
abcdefghijABCDrt   r   )br   r6   r   )r   r   )jr   zCindex 5 is out of bounds for axis 0 with size 4|index out of boundsrh   )rn   rd   zLocation based indexing can only have \[integer, integer slice \(START point is INCLUDED, END point is EXCLUDED\), listlike of integers, boolean array\] types)r   rG   rw   rx   r|   ry   r%   r   rI   rJ   r2   rz   r(   
ValueError)r)   rM   r   r   rO   r}   r,   r,   r-    test_iloc_getitem_labelled_frameY  s.   



"z8TestiLocBaseIndependent.test_iloc_getitem_labelled_framec                 C   s  t jdd}tddd}td}t|||d}|  |jdd	d
df }t|dd	d
df |dd	 |d
d d}t	
|| td|_|jdd	d
df }t|dd	d
df |dd	 tdd}t	
|| t jdd}ttd
dd}ttd
dd}t|||d}|s|jjd
 j |jdd	ddf }t|dd	ddf |dd	 |dd d}t	
|| d S )Nr   )ru   rS   20130101ru   )periodsr   rt   r6   rd   r   aaaaaar   r   r   rS   )rG   rw   rx   r|   r   ry   r   describer%   rI   rJ   rg   r?   rA   rB   mgr_locs)r)   rK   rZ   r]   rg   rM   r   rO   r,   r,   r-   test_iloc_getitem_doc_issue|  s*   .
*.z3TestiLocBaseIndependent.test_iloc_getitem_doc_issuec                 C   s`  t tjddtdtdd}d|jd< |jd }|dks"J d|jd d dd	f< |jd d dd	f }|jd d dd	f }t|| t	tjdd
t
dddd}d|jd< |jd }|dksjJ d|jd d< |jd d }|jd d }t|| t	dgd }g d|jdd d< g d|jdd d< |}t	g d}t|| d S )Nr   r   r   r   rt   r   r   r   r6   rn   rc   r\   rS   r   ru   )r   r   rS   )r   r6   rd   rj   )r   rG   rw   rx   r|   ry   r%   rI   rJ   r   r?   r{   )r)   rM   r   rO   r~   r,   r,   r-   test_iloc_setitem_series  s4   

"

z0TestiLocBaseIndependent.test_iloc_setitem_seriesc                 C   s   t tjdddtjddddd}ddgddgg|jd	d
< t g dg dd}t|| t g dtjddddd}ddgddgg|jd	d
< t g dg dd}t|| d S )Nrd   int64r8   rn   r   rp   r   r   r   rS   )r   r   rn   r   rS   )rd   ru   rp   r   r   r   r   r   r   r   r   y)r   r   r   r   r   )r   rG   r   r%   rI   rJ   r   r,   r,   r-   test_iloc_setitem_list_of_lists  s   z7TestiLocBaseIndependent.test_iloc_setitem_list_of_listsr   valueZc                 C   sV   t ddgddggddgddti}||jd|f< |jd	 }t|r'|d
ks)J d S )Nr   r   r6   rS   rm   r   rf   r   r=   r   )r   rF   r@   r%   r   )r)   r7   r   rM   r   r,   r,   r-   #test_iloc_setitem_with_scalar_index  s   &
z;TestiLocBaseIndependent.test_iloc_setitem_with_scalar_indexzignore::UserWarningc                 C   s  t ttdtddgd}|jd dk}d}tjt|d |j|  W d    n1 s.w   Y  tt||_	d	}tjt
|d |j|  W d    n1 sSw   Y  |jtjd
gt| td }t|| td}d| }dd |D }t ||d|}ddddddddd	d	}dD ]r}	|jdkj}|	rt||	d d d }
t|t|
}dD ]T}z|rt||dd  }n|}tt|| d  }W n ttt
fy } z
t|}W Y d }~nd }~ww |	|f}||}||krtd| d| d| dqqd S )Nrd   re   r   rt   r   r   zBiLocation based boolean indexing cannot use an indexable as a maskrh   zDiLocation based boolean indexing on an integer type is not availableTr8   rS   c                 S   s   g | ]}t |qS r,   )bin).0numr,   r,   r-   
<listcomp>  s    z:TestiLocBaseIndependent.test_iloc_mask.<locals>.<listcomp>)locsnums0b11000b11ztUnalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).)	)N )N.loc)N.iloc)r]   r   )r]   r  )r]   r  )r   r   )r   r  )r   r  )Nr]   r   r   )r   r  r  r   r   [z] does not match [z], received [])r   ry   r?   r   r2   rz   r   r%   r   r]   NotImplementedErrorrG   r   boolrI   rJ   r   r   rE   getattrr   strr   sumr   getAssertionError)r)   rM   r   r}   r   r   r   repsrO   idx
mask_indexmethodaccessoranswererrr   rr,   r,   r-   test_iloc_mask  sj   


z&TestiLocBaseIndependent.test_iloc_maskc                 C   s   t dgd dgd d}tdd }|j| }t|d| d| g}|j| }t|| t dgd	 dgd	 d}t|d| d| g}tjt	d
d |j
|  W d    d S 1 s_w   Y  d S )N皙?r   r   r   rk   c   r   r6   r   znot in indexrh   )r   rG   r   r%   r   rI   rJ   r2   rz   KeyErrorr   )r)   rM   r  rO   df3r   r   r,   r,   r-   test_iloc_non_unique_indexing'  s   

"z5TestiLocBaseIndependent.test_iloc_non_unique_indexingc                 C   s   t tdtdd tdD ddtdd tdD ddd	}tj|jd d g f |jd d d d
f ddd tj|jg d d f |jd d
d d f ddd tj|jg  |jd d
d d f ddd d S )Nrr   c                 S      g | ]}d | qS zi-r,   r   ir,   r,   r-   r   ;      zNTestiLocBaseIndependent.test_iloc_empty_list_indexer_is_ok.<locals>.<listcomp>rd   r   r   c                 S   r  r  r,   r  r,   r,   r-   r   <  r  r   rt   r   T)check_index_typecheck_column_type)r   rG   onesr   r?   rI   rJ   r%   r)   rM   r,   r,   r-   "test_iloc_empty_list_indexer_is_ok8  s(    
z:TestiLocBaseIndependent.test_iloc_empty_list_indexer_is_okc                 C   sX  t dg di}|jd d  }||usJ t|d |d s!J t| g d|jd d df< W d    n1 s<w   Y  |rP|d g dk sOJ n
|d dk sZJ tg d}|jd d  }||usmJ t| g d|d d< W d    n1 sw   Y  |rt|d d g dksJ d S t|d d g dksJ d S )Nr   r   )rS   rS   rS   rS   )r   r   r6   rS   rd   ru   r   r   r   r6   )	r   r%   rG   rH   rI   assert_cow_warningr   allr   )r)   rY   r   original_df	sliced_dforiginal_seriessliced_seriesr,   r,   r-   &test_identity_slice_returns_new_objectQ  s&     z>TestiLocBaseIndependent.test_identity_slice_returns_new_objectc                 C   sD   t ddgddgg}|jtd }tddgdd}t|| d S )Nr   r   r6   rS   r   r  )r   r%   rG   r   r   rI   r{   )r)   rM   r   r~   r,   r,   r-   test_indexing_zerodim_np_arrayr  s   z6TestiLocBaseIndependent.test_indexing_zerodim_np_arrayc                 C   s,   t ddg}|jtd }|dksJ d S )Nr   r   r   )r   r%   rG   r   )r)   r~   r   r,   r,   r-   %test_series_indexing_zerodim_np_arrayy  s   z=TestiLocBaseIndependent.test_series_indexing_zerodim_np_arrayc                 C   s   t g d}t|g dddd}t|d |sJ |d d d |jd d df< t|d |s3J t g d	g dd
}t|| d S )Nr   r   )r   r   F)rD   r   r   r   )r   r   rm   
categories)r   r   rI   rH   r%   assert_categorical_equal)r)   rL   rM   rO   r,   r,   r-   -test_iloc_setitem_categorical_updates_inplace  s   zETestiLocBaseIndependent.test_iloc_setitem_categorical_updates_inplacec                 C   s:  t ddgddgddgdtjgg}|j|jdk  d9  < t ddgddgdd	gdtjgg}t|| |j|jdk  d9  < t ddgddgdd	gd
tjgg}t|| |jg d  d9  < t ddgdd
gdd	gd
tjgg}t|| |jg d  d  < t ddgddgddgdtjgg}t|| d S )Nr   r   r   r6   rS   rd   ru   r   rn   r   )TTFF)FFTTg      @g      (@g      @)r   rG   r   r%   r]   rI   rJ   r)   r   rO   r,   r,   r-    test_iloc_with_boolean_operation  s   """""z8TestiLocBaseIndependent.test_iloc_with_boolean_operationc                 C   sR   t dtd i}|jd }tdgg dd}t|dgddd}t|| d S )	Nr   z	a b c d er   r   r   r/  category)r]   r   r9   )r   r   splitr%   r   rI   r{   )r)   rM   r   raw_catrO   r,   r,   r-   ?test_iloc_getitem_singlerow_slice_categoricaldtype_gives_series  s
   
zWTestiLocBaseIndependent.test_iloc_getitem_singlerow_slice_categoricaldtype_gives_seriesc                 C   s   t g dd}|jdd }t ddgtg d}t|| |jddg }t ddgtg d}t|| |jg d }t dgtg d}t|| d S )Nr   r5  r   r   r   TFF)r   rF   r%   r   rI   r{   )r)   ra   r   rO   r,   r,   r-   $test_iloc_getitem_categorical_values  s   z<TestiLocBaseIndependent.test_iloc_getitem_categorical_valuesc                 C   s<   t g ddd}||jd< t tddgdd}t|| d S )Nr   ztimedelta64[ns]r8   r   r   r   )r   r%   r
   rI   r{   )r)   r   r   rO   r,   r,   r-   %test_iloc_setitem_td64_values_cast_na  s   
z=TestiLocBaseIndependent.test_iloc_setitem_td64_values_cast_nanot_nar   g      ?c                 C   sX   t |gd}t||||g|d}|||g|jd d< t||||g|d}t|| d S )Nr/  r8   r6   )r   r   r%   rI   r{   )r)   r<  nulls_fixturer9   ra   r   r,   r,   r-   $test_setitem_mix_of_nan_and_interval  s   z<TestiLocBaseIndependent.test_setitem_mix_of_nan_and_intervalc                 C   s   t g }ttjdt|t|f||d}tjdjddd}d|j }t	j
t|d d|j|< W d    d S 1 sAw   Y  d S )	Nr   rt   rd   )r   r   r   r   zCannot set values with ndim > rh   r   )r   r   rG   rw   rx   r|   r   r   ndimr2   rz   r   r%   )r)   r  r+   nd3r}   r,   r,   r-   4test_iloc_setitem_empty_frame_raises_with_3d_ndarray  s   "zLTestiLocBaseIndependent.test_iloc_setitem_empty_frame_raises_with_3d_ndarrayc                 C   s   t d}t|}t d}|jdd t|}t||g d ||g d  t||dg ||dg  t||d ||d  t||dd ||dd  d S )Nrn   F)writer   r   r6   )rG   eyer   setflagsrI   rJ   r{   )r)   r7   rw_arrayrw_dfro_arrayro_dfr,   r,   r-   "test_iloc_getitem_read_only_values  s   

$ (z:TestiLocBaseIndependent.test_iloc_getitem_read_only_valuesc                 C   s   t dtjdddi}tg d}d|j_|j| }|jg d }t	|| |d j| }|d jg d }t
|| d S )Ndatarl   float64r8   )r   r6   ru   F)r   rG   r"  r   flags	writeabler%   r   rI   rJ   r{   )r)   rM   indicesr   rO   r,   r,   r-   test_iloc_getitem_readonly_key  s   
z6TestiLocBaseIndependent.test_iloc_getitem_readonly_keyc                 C   sR   t dgdgd}tg d|jd< t dtg dgidgdgd}t|| d S )Nr   r   rg   r]   r   r=   )r   r   r%   rI   rJ   r   r,   r,   r-   "test_iloc_assign_series_to_df_cell  s    z:TestiLocBaseIndependent.test_iloc_assign_series_to_df_cellklassc                 C   sd   t g dg dd}|g d}|j|df d |j|df< t g dg dd}t|| d S )N)r   r   z)r   r6   rS   )flagr   r9  r   r   )r   r6   rS   r   )r)   rR  rM   r7   rO   r,   r,   r-   test_iloc_setitem_bool_indexer  s
   z6TestiLocBaseIndependent.test_iloc_setitem_bool_indexerr   c                 C   s   t g dg dd}t g dg dg dd}|jd d dgf |jd d |f< t g dg dg dd}t|| d S )	N)rp   r   r   )r         )a2b2r   rv   r%  r   r   r   r   r   )r)   r7   r   r   rO   r,   r,   r-   %test_iloc_setitem_pure_position_based  s
   "z=TestiLocBaseIndependent.test_iloc_setitem_pure_position_basedc                 C   s   t ddgddgd}ddd}||jd< t ddgddgd}t|| t ddgddgd}||jd< t ddgddgd}t|| d S )Nr   r   )r   r   r   r  g       @g     X@r   )r)   rM   rhsrO   r,   r,   r-   "test_iloc_setitem_dictionary_value  s   


z:TestiLocBaseIndependent.test_iloc_setitem_dictionary_valuec                 C   sp  t tjddg dtdd}|jdd  }t|j	d | |jdd df }t
|j	d	 | g d
|_|jdd  }t|j	d | |jdd df }t
|j	d	 | t tjddg dtdd}|jdd }t|j	d | |jdddf }t
|j	d	 | g d|_|jddg }t|j	d | |jddgdf }t
|j	d	 | d S )Nr   r   )r  皙?r^  abcrt   r   r^  r   )r^  r   )r   r^  r^  )rS   r6   )r   r^  r^  r   r   )r  r^  r   r^  )r   rG   rw   rx   r|   ry   r%   rI   rJ   r   r{   r]   )r)   rM   expectr,   r,   r-   "test_iloc_getitem_float_duplicates$  s8   

z:TestiLocBaseIndependent.test_iloc_getitem_float_duplicatesc                 C   s   G dd d}t ddgdgd}|d|jd< |d|jd< t ddgdgd}|d|jd< t|| t ddgdgd}|d|jd< tj|jd< t ddgdgd}t|| d S )Nc                   @   s>   e Zd ZdddZdefddZeZdefddZd	d
 Z	dS )zCTestiLocBaseIndependent.test_iloc_setitem_custom_object.<locals>.TOreturnNc                 S   s
   || _ d S Nr   )r)   r   r,   r,   r-   __init__L  s   
zLTestiLocBaseIndependent.test_iloc_setitem_custom_object.<locals>.TO.__init__c                 S   s   d| j  dS )Nr  r  rd  r)   r,   r,   r-   __str__O  s   zKTestiLocBaseIndependent.test_iloc_setitem_custom_object.<locals>.TO.__str__c                 S   s   | j |j kS rc  rd  )r)   otherr,   r,   r-   __eq__T  s   zJTestiLocBaseIndependent.test_iloc_setitem_custom_object.<locals>.TO.__eq__c                 S   s   | S rc  r,   rf  r,   r,   r-   viewW  s   zHTestiLocBaseIndependent.test_iloc_setitem_custom_object.<locals>.TO.view)rb  N)
r/   r0   r1   re  r  rg  __repr__r  ri  rj  r,   r,   r,   r-   TOK  s    
rl  r   r   rt   r^   r   )r   r%   rI   rJ   rG   r   )r)   rl  rM   r   r,   r,   r-   test_iloc_setitem_custom_objectI  s   z7TestiLocBaseIndependent.test_iloc_setitem_custom_objectc                 C   s   t tjddtdtdd}|jd }t|tsJ t	|j
|j
d  |jjd d df }t|ts9J t	|j
|j
d  d S )Nr   r   ABCaabrP  r   )r   rG   rw   rx   ry   r%   
isinstancer   rI   assert_almost_equalrE   T)r)   rM   r   r,   r,   r-   !test_iloc_getitem_with_duplicatesk  s   
z9TestiLocBaseIndependent.test_iloc_getitem_with_duplicatesc                 C   sP   t g dg dgg dd}|jd d dgf }|jdgdd}t|| d S )Nr   rv   )r   r   r   rf   r   r   r   )r   r%   takerI   rJ   r)   rM   r   rO   r,   r,   r-   "test_iloc_getitem_with_duplicates2z  s   z:TestiLocBaseIndependent.test_iloc_getitem_with_duplicates2c                 C   s   t tddddgi}|jd }ttdddidd}t|| |jd d df }tddgtddd}t|| | }|jd d df  d7  < t tddddgi}t|| d S )Nr   r   r   r  r6   )r   r	   r%   r   rI   r{   rD   rJ   ru  r,   r,   r-   test_iloc_interval  s   
z*TestiLocBaseIndependent.test_iloc_intervalindexing_funcrhs_funcc                 C   s   t g d}|ddg|j|g d< t g d}t|| tdg di}|dgdgg|j|g d< tdg di}t|| d S )Nr   rd   rn   TFT)rd   r   rn   r   )r   r%   rI   r{   r   rJ   )r)   ry  rx  ra   rO   rM   r,   r,   r-   test_loc_setitem_boolean_list  s   z5TestiLocBaseIndependent.test_loc_setitem_boolean_listc                 C   s~   t dg didd}|jd d d d df }t|| d|d< |jd d d d df }t |d |d d}t|| d S )	Nrm   r   Int64r8   r   foor   )r   rm   r   )r)   rM   resrO   r,   r,   r-   .test_iloc_getitem_slice_negative_step_ea_block  s   zFTestiLocBaseIndependent.test_iloc_getitem_slice_negative_step_ea_blockc                 C   sl   t dg didd}tdgdgg|jtddgtdgf< t dg di|d jd}t|| d S )	NstatusrZ  r5  r8   r   r   r   )r   r   r   )r   rG   r   r%   r9   rI   rJ   r   r,   r,   r-   *test_iloc_setitem_2d_ndarray_into_ea_block  s   .zBTestiLocBaseIndependent.test_iloc_setitem_2d_ndarray_into_ea_blockc                 C   sV   t ddj}t|}|jd }|d |d ksJ |d |d< |d |d ks)J d S )Nr   g      $@r   r   r   )r   _valuesr   r%   )r)   rZ   rM   ra   r,   r,   r-   *test_iloc_getitem_int_single_ea_block_view  s   
zBTestiLocBaseIndependent.test_iloc_getitem_int_single_ea_block_viewc                 C   sl   t ddgddgd}t dtddgi|jd d dgf< t tdtd	gddgd}tj||d
d d S )Nz
2022-01-01z
2022-01-0220212022r   rm   r   z2021-01-01 00:00:00z2022-01-01 00:00:00F)check_dtype)r   r   r%   r   rI   rJ   r   r,   r,   r-   )test_iloc_setitem_multicolumn_to_datetime  s   $	zATestiLocBaseIndependent.test_iloc_setitem_multicolumn_to_datetime)Qr/   r0   r1   __doc__r2   r3   r4   slicer?   r   rG   asarrayrI   r   r%   rP   r   r   r[   rb   r   r   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   filterwarningsr  r  r$  r,  r-  r.  r2  r4  r8  r:  r
   r   r;  r	   r>  rA  rI  rO  rQ  rU  r[  r]  ra  rm  rs  rv  rw  r{  r  r  td&skip_array_manager_not_yet_implementedr  r  r,   r,   r,   r-   r5   <   s    
 

e	
1#$"$

E!	





%"
r5   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestILocErrorsc              	   C   s   |}|t u r
| }d}tjt|d |jd  W d    n1 s#w   Y  tjttd/ t	|o7|t u  d|jd< W d    n1 sIw   Y  W d    d S W d    d S 1 saw   Y  d S )Nz5Cannot index by location index with a non-integer keyrh   g      @r   )
r   r`   r2   rz   r   r%   r(   _slice_iloc_msgrI   r&  )r)   series_with_simple_indexrX   r   r+   r}   r,   r,   r-   test_iloc_float_raises  s    

"z%TestILocErrors.test_iloc_float_raisesc                 C   s   t jtdd |jd d d d d d f  W d    n1 s w   Y  t jtdd d|jd d d d d d f< W d    d S 1 sFw   Y  d S )NzToo many indexersrh   ztoo many indices for arrayr   )r2   rz   r   r%   r(   )r)   float_framer,   r,   r-   *test_iloc_getitem_setitem_fancy_exceptions  s   "z9TestILocErrors.test_iloc_getitem_setitem_fancy_exceptionsc                 C   s   t dg di}t dg di}d}tjt|d d|j|< W d    n1 s)w   Y  d}tjt|d |j|  W d    d S 1 sHw   Y  d S )Nr   r   rz  zADataFrame indexer for .iloc is not supported. Consider using .locrh   r   zWDataFrame indexer is not allowed for .iloc
Consider using .loc for automatic alignment.)r   r2   rz   r   r%   r(   )r)   rM   r7   r}   r,   r,   r-   test_iloc_frame_indexer  s   "z&TestILocErrors.test_iloc_frame_indexerN)r/   r0   r1   r  r  r  r,   r,   r,   r-   r    s    r  c                   @   sB   e Zd Zdd Zdd Zdd Zejg ddd	gd
d Z	dS )TestILocSetItemDuplicateColumnsc                 C   s   t d dddddg}t ddddddg}t||gdd}d|jd< |jd dks.J |jd	 dks7J |jjd tjksBJ d S )
Nr   r   r   r6   rS   r   r   r=   )r   r   )r   r   r%   dtypesrG   r   )r)   r   r   rM   r,   r,   r-   *test_iloc_setitem_scalar_duplicate_columns  s   
zJTestILocSetItemDuplicateColumns.test_iloc_setitem_scalar_duplicate_columnsc                 C   sP   t g dgg dd}dg|jd d df< t g dgg dd}t|| d S )N)r   r  str2r   r   r   rf   str3r   )r   r  r  r   r   r,   r,   r-   (test_iloc_setitem_list_duplicate_columns  s   zHTestILocSetItemDuplicateColumns.test_iloc_setitem_list_duplicate_columnsc                 C   sf   t tjdtjdddg dd}|jd d df tj|jd d df< |jjd tjks1J d S )Nr   r8   r   rS   r   rf   r   )	r   rG   r   r   r   r%   rF   rK  r  r#  r,   r,   r-   *test_iloc_setitem_series_duplicate_columns  s
   (zJTestILocSetItemDuplicateColumns.test_iloc_setitem_series_duplicate_columns)r  
init_valueexpected_value)r   0r   )floatz1.2g333333?c                 C   sj   t |ddggg dtd}|jd d df ||jd d df< t |ddggg dtd}t|| d S )Nr  r  r  )rg   r9   r   )r   r@   r%   rF   rI   rJ   )r)   r  r  r  rM   expected_dfr,   r,   r-   *test_iloc_setitem_dtypes_duplicate_columns#  s   &
zJTestILocSetItemDuplicateColumns.test_iloc_setitem_dtypes_duplicate_columnsN)
r/   r0   r1   r  r  r  r2   r3   r4   r  r,   r,   r,   r-   r    s    	r  c                   @   s   e Zd Zdd Zdd ZdS )TestILocCallablec                 C   s  t g dtddtdd}|jdd  }t||jdd	g  |jd
d d d f }t||jdd	gd d f  |jdd dd f }t||jdd	gdf  |jdd dd f }t||jdd	gdgf  |jdd	gdd f }t||jdd	gdf  |jdd	gdd f }t||jdd	gdgf  |jdd df }t||jdd	gdf  |jdd dgf }t||jdd	gdgf  d S )NrR   aabbXYr   r\   c                 S   r   Nr   r6   r,   r   r,   r,   r-   r   A  r   zCTestILocCallable.test_frame_iloc_getitem_callable.<locals>.<lambda>r   r6   c                 S   r   r  r,   r   r,   r,   r-   r   D  r   c                 S   r   r  r,   r   r,   r,   r-   r   G  r   c                 S      dS Nr   r,   r   r,   r,   r-   r   G      r   c                 S   r   r  r,   r   r,   r,   r-   r   J  r   c                 S      dgS r  r,   r   r,   r,   r-   r   J      c                 S   r  r  r,   r   r,   r,   r-   r   N  r  c                 S   r  r  r,   r   r,   r,   r-   r   Q  r  c                 S   r   r  r,   r   r,   r,   r-   r   T  r   c                 S   r   r  r,   r   r,   r,   r-   r   W  r   )r   ry   r%   rI   rJ   r{   )r)   rM   r~  r,   r,   r-    test_frame_iloc_getitem_callable<  s"    z1TestILocCallable.test_frame_iloc_getitem_callablec                 C   sJ  t g dttdtddtdd}| }d|jdd	 < | }d|jd
dg< t|| | }d|jdd	 d d f< | }d|jd
dgd d f< t|| | }d|jdd	 dd	 f< | }d|jd
dgdf< t|| | }d|jdd	 dd	 f< | }d|jd
dgdgf< t|| | }d|jd
dgdd	 f< | }d|jd
dgdf< t|| | }d|jd
dgdd	 f< | }d|jd
dgdgf< t|| | }d|jdd	 df< | }d|jd
dgdf< t|| | }ddg|jdd	 dgf< | }ddg|jd
dgdgf< t|| d S )NrR   r  r8   r  r   r\   r   c                 S   r   r  r,   r   r,   r,   r-   r   c  r   zCTestILocCallable.test_frame_iloc_setitem_callable.<locals>.<lambda>r   r6   r   c                 S   r   r  r,   r   r,   r,   r-   r   i  r   rd   c                 S   r   r  r,   r   r,   r,   r-   r   o  r   c                 S   r  r  r,   r   r,   r,   r-   r   o  r     c                 S   r   r  r,   r   r,   r,   r-   r   u  r   c                 S   r  r  r,   r   r,   r,   r-   r   u  r  r   c                 S   r  r  r,   r   r,   r,   r-   r   |  r  c                 S   r  r  r,   r   r,   r,   r-   r     r  rn   c                 S   r   r  r,   r   r,   r,   r-   r     r   c                 S   r   r  r,   r   r,   r,   r-   r     r   )r   r   ry   r@   rD   r%   rI   rJ   )r)   rM   r~  r   r,   r,   r-    test_frame_iloc_setitem_callableZ  sX   z1TestILocCallable.test_frame_iloc_setitem_callableN)r/   r0   r1   r  r  r,   r,   r,   r-   r  ;  s    r  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestILocSeriesc           	   	   C   sL  t tjddttdddd}| }tt|D ]}|j	| }||j
|  }t|| q|j	tdd }|jdd }t|| td # t| d|d d < W d    n1 scw   Y  W d    n1 srw   Y  |rt|| n|j	dd dk sJ |j	g d	 }||j
g d	 }t|| d S )
Nr   rn   r   rc   r\   r   r6   rS   )r   r   r6   rS   rd   )r   rG   rw   rx   r|   ry   r?   rD   r   r%   r]   rI   rq  r  r   r{   r   r&  r'  reindex)	r)   rY   r   ra   ser_originalr  r   r   rO   r,   r,   r-   	test_iloc  s.   
zTestILocSeries.test_ilocc                 C   s*   t g dg dd}|jd dksJ d S )Nr   r   r\   r   )r   r%   )r)   ra   r,   r,   r-   test_iloc_getitem_nonunique  s   z*TestILocSeries.test_iloc_getitem_nonuniquec                 C   sT   t g d}t g dg dd}|jdd |jdd< t g d}t|| d S )Nr   rv   )r   r   r   r\   r   r6   )r   rd   ru   )r   r%   rI   r{   )r)   ser1ser2rO   r,   r,   r-   r[    s
   z4TestILocSeries.test_iloc_setitem_pure_position_basedc                 C   s   t dgtjgd}tjtdd |jd d df d|jd d df< W d    n1 s/w   Y  t dgtt	gddd}t
|| d S )Ntest)r   r   r   rh   r   r|  r8   )r   rG   r   rI   r   r   r   rF   r   r   rJ   r3  r,   r,   r-   #test_iloc_nullable_int64_size_1_nan  s   (z2TestILocSeries.test_iloc_nullable_int64_size_1_nanN)r/   r0   r1   r  r  r[  r  r,   r,   r,   r-   r    s
    r  )+r  r   renumpyrG   r2   pandas.errorsr   pandas.util._test_decoratorsutil_test_decoratorsr  pandasr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   pandas._testing_testingrI   pandas.api.typesr   pandas.tests.indexing.commonr   escaper  r   r5   r  r  r  r  r,   r,   r,   r-   <module>   s:    D         !34Y