
    Pih                         d Z ddlmZmZ ddlZddl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mZ ddlmZ ej        d             Z G d d          Z G d	 d
          Z G d d          ZdS )z/
See also: test_reindex.py:TestReindexSetIndex
    datetime	timedeltaN)Pandas4Warning)
CategoricalCategoricalIndex	DataFrameDatetimeIndexIndex
MultiIndexSeries
date_rangeperiod_rangeto_datetimec            
      ^   t          g dg dg dt          j                            d                              d          t          j                            d                              d          t          j                            d                              d          d          } | S )aM  
    Fixture for DataFrame of columns that can be used for indexing

    Columns are ['A', 'B', 'C', 'D', 'E', ('tuple', 'as', 'label')];
    'A' & 'B' contain duplicates (but are jointly unique), the rest are unique.

         A      B  C         D         E  (tuple, as, label)
    0  foo    one  a  0.608477 -0.012500           -1.664297
    1  foo    two  b -0.633460  0.249614           -0.364411
    2  foo  three  c  0.615256  2.154968           -0.834666
    3  bar    one  d  0.234246  1.085675            0.718445
    4  bar    two  e  0.533841 -0.005702           -3.533912
    )foor   r   barr   )onetwothreer   r   )abcde      )ABCDEtupleaslabel)r	   nprandomdefault_rngstandard_normal)dfs    }/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/frame/methods/test_set_index.pyframe_of_index_colsr-      s     
444666***&&q))99!<<&&q))99!<<&(i&;&;A&>&>&N&Nq&Q&Q	
 	
	
 	
B I    c                   .   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zej                            d
ddddgdg          ej                            dddg          ej                            dddg          d                                     Zej                            d
ddddgdg          ej                            dddg          d                         Zej                            d
ddddgdg          ej                            dddg          d                         Zd Zej                            deeej        ed d g          ej                            dg d          ej                            dddg          d                                     Zej                            deeej        ed g          ej                            dg d          ej                            dddg          d                                     Zej                            d eeej        eed! d" g          ej                            d#eeej        eed$ d% g          ej                            dg d&          ej                            dddg          d'                                                 Zej                            d(ddg          ej                            dddg          d)                         Zd* Zd+ Zd, Zd- Z d.S )/TestSetIndexc                     g dg dd}t          |          }g d}||d<   t          j        |d                   }|                    |           d S )N)r   g      @   )   r      )t1t2))r      )r   r   )r7   r   tuples)r	   r   from_tuples	set_index)selfr   r+   r8   indexs        r,   test_set_index_multiindexz&TestSetIndex.test_set_index_multiindex;   sb    ;;iii00q\\)))8&r(|44
Ur.   c           	         t          ddddddddd	d
dddd
gg d          }|                    ddg          }|ddg         }t          j        |d         |d         gddg          |_        t          j        ||           d S )Nr7   r   )r   pr   
   )r   mr2         )r   rA   r?   r3         )r   rA   r?   xcolumnsr   rF   rA   r?   names)r	   r:   r   from_arraysr<   tmassert_frame_equal)r;   r+   resultexpecteds       r,   test_set_index_empty_columnz(TestSetIndex.test_set_index_empty_columnF   s    a  b!!br**br**	 )((
 
 
 sCj))sCj>#/C"S'0B3PS*UUU
fh/////r.   c                    t          t          d          t          d          g d          }|                    ddg          }|j                                        j        }|ddg         j        }t          j        ||           d S )Nzdatetime64[ns]dtypeint64r   r   r   r   r   )r	   r   r:   r<   to_framedtypesrL   assert_series_equal)r;   df1df2rN   rO   s        r,   test_set_index_empty_dataframez+TestSetIndex.test_set_index_empty_dataframeX   s    /000vG7L7L7LSUVV
 
 mmS#J''##%%,Sz?)
vx00000r.   c                    t          j        g d          }t          t          j                            d                              d          |          }|                    |j        d                   }|j	        d d dd f         }|j	        d d df         j
        |_        |j        d         g|j        _        t          j        ||           d S )N))r   r7   )r   r   )r   r7   r   )r2   r2   rG   r   r7   )r   r9   r	   r'   r(   r)   r*   r:   rH   ilocvaluesr<   rJ   rL   rM   )r;   rH   r+   rN   rO   s        r,    test_set_index_multiindexcolumnsz-TestSetIndex.test_set_index_multiindexcolumnsc   s    ()M)M)MNNI!!!$$44V<<g
 
 
 bjm,,7111abb5>A- "
1
fh/////r.   c                    t          dgd                              d          }t          d|i          }|                    |          j        d         j        dk    sJ t          t          |j                            d         j        dk    sJ |                    |j                  j        d         j        dk    sJ d S )Nz2014-01-01 10:10:10UTCtzzEurope/Romer   r   rB   )r
   
tz_convertr	   r:   r<   hourr   r   )r;   idxr+   s      r,   test_set_index_timezonez$TestSetIndex.test_set_index_timezonep   s     23>>>II-XXSz""||C  &q)."4444VBD\\**1-2b8888||BD!!'*/2555555r.   c                    t          d t          d          D             t          j                            d                              d          d          }|                    d          }t          |j        t                    sJ d S )Nc                 P    g | ]#}t          d dd          t          |          z   $S )i  r7   r   .0is     r,   
<listcomp>zBTestSetIndex.test_set_index_cast_datetimeindex.<locals>.<listcomp>|   s/    OOOahtQ**Yq\\9OOOr.   i  r   r   r   r   )
r	   ranger'   r(   r)   r*   r:   
isinstancer<   r
   )r;   r+   idfs      r,   !test_set_index_cast_datetimeindexz.TestSetIndex.test_set_index_cast_datetimeindexy   s    OO5;;OOOY**1--==dCC 
 
 ll3#)]3333333r.   c                    t          dddd          }t          g dg dd|	                                          }|                    d
          }t          g dg ddt	          |d
          	          }|j                            d           |_        t          j        ||           |                    d
dg          }t          j
        |g dgd
dg          }t          dg di|          }t          j        ||           d S )Nz2006-10-29 00:00:00r2   h
US/Pacific)periodsfreqrc   r   r7   r   )r2   r3   r   )r   r   )datar<   r<   namer   rI   r   r<   )r   r	   reset_indexr:   r   r<   
_with_freqrL   rM   r   rK   )r;   dir+   resexp	exp_indexs         r,   test_set_index_dstzTestSetIndex.test_set_index_dst   s'   -qs|TTT))))))<<BGGGSSUUll7## yyyyy11)))
 
 
 I((..	
c3''' llGS>***B			?7C.QQQ	iii(	:::
c3'''''r.   c                    |}t          t          j        t          |          dz
  ddt          j                            }|                    |          }t          j        |j        |           t          j
        t          d          5  |                    |d d d                    d d d            d S # 1 swxY w Y   d S )Nr7   rR   zLength mismatchmatchr   )r   r'   arangelenrT   r:   rL   assert_index_equalr<   pytestraises
ValueError)r;   float_string_framer+   rf   s       r,   test_set_indexzTestSetIndex.test_set_index   s    BIc"ggk2rBBBCC\\#
bh,,,]:->??? 	# 	#LLSSqS"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   B88B<?B<c           
      Z   t          t          j        d          t          t	          d          t
                    t          d t          d          D             t
                              }d|j        _        |	                    |j                  j        j
        dgk    sJ t          j        |dd	g         j        j        dd	g
          }t          j        |g d         j        j        g d
          }|	                    dd	g          }|	                    |j                  j        j
        dd	gk    sJ t          |	                    |j                  j        t                    sJ t!          j        |	                    |j                  j        |           |j                            ddg          }t          |	                    |j        |g          j        t                    sJ t!          j        |	                    |j        |g          j        |           d S )N)r@   r3   ABCDrR   c                     g | ]}d | S )zi- rj   s     r,   rm   z5TestSetIndex.test_set_index_names.<locals>.<listcomp>   s    555aa555r.   r@   )rH   r<   r{   r   r   rI   )r   r   r   r   )r   r   r    r!   r    r!   )r	   r'   onesr   listobjectro   r<   r{   r:   rJ   r   rK   Tr^   rp   rL   r   rename)r;   r+   mimi2idx2s        r,   test_set_index_namesz!TestSetIndex.test_set_index_names   s   GG$v,,f55555599555VDDD
 
 

 ||BH%%+1fX====#BSzN$4$;C:NNN$###$&-5I5I5I
 
 
 \\3*%%||BH%%+1c3Z???? ",,rx006
CCCCC 	bll2844:B???xSz** ",,$'788>
KKKKK 	bllBHd+;<<BCHHHHHr.   keysr   r    r   r#   inplaceTFdropc                   	 |	t          |t                    r#t          j        	fd|D             |          }nt	          	|         |          }|r	                    |d          n	}||_        |r1	                                }|                    ||d          }|J n	                    ||          }t          j
        ||           d S )	Nc                      g | ]
}|         S r   r   rk   rF   r+   s     r,   rm   z<TestSetIndex.test_set_index_drop_inplace.<locals>.<listcomp>   s    )>)>)>A"Q%)>)>)>r.   rI   rz   r7   axisT)r   r   )r   )rp   r   r   rK   r   r   r<   copyr:   rL   rM   )
r;   r-   r   r   r   rf   rO   rN   return_valuer+   s
            @r,   test_set_index_drop_inplacez(TestSetIndex.test_set_index_drop_inplace   s     !dD!! 	-()>)>)>)>)>)>)>dKKKCC4t,,,C,082774a7(((b 	3WWYYF!++DtT+JJL''''\\$T\22F
fh/////r.   c                 ^   |t          |t                    r|n|g}t          j        j        gfd|D             z   d g|          }|r                    |d          n                                }||_                            ||d          }t          j	        ||           d S )Nc                      g | ]
}|         S r   r   r   s     r,   rm   z6TestSetIndex.test_set_index_append.<locals>.<listcomp>   s    ...A"Q%...r.   rI   r7   r   Tr   append)
rp   r   r   rK   r<   r   r   r:   rL   rM   )r;   r-   r   r   rf   rO   rN   r+   s          @r,   test_set_index_appendz"TestSetIndex.test_set_index_append   s     !!$--9ttD6$XJ........tmdm
 
 
 -1?2774a7(((bggiidd;;
fh/////r.   c                     |                     dg|d          }t          |t                    r|n|g}|                     dg||d          }|                     ||d          }t          j        ||           d S )Nr!   Tr   )r:   rp   r   rL   rM   )r;   r-   r   r   r+   rO   rN   s          r,   #test_set_index_append_to_multiindexz0TestSetIndex.test_set_index_append_to_multiindex   s     !**C5tD*II!$--9ttD6&00#DQU0VVdd;;
fh/////r.   c                    t          g dg dd          }t          dddgit          ddgd	
                    }|j        |j                            d                    }|                    d	          }t          j        ||           d S )Nrx   rU   )valkeyr   r7   r   r   r   r   rz   c                     | dk    S )Nr7   r   )indxs    r,   <lambda>z<TestSetIndex.test_set_index_after_mutation.<locals>.<lambda>   s
    tqy r.   )r	   r   locr<   mapr:   rL   rM   )r;   r+   rO   rZ   rN   s        r,   test_set_index_after_mutationz*TestSetIndex.test_set_index_after_mutation   s    yyyAABBeaV_eS#JU.K.K.KLLfRX\\"8"899:u%%
fh/////r.   boxc                 "    t          |           gS N)r   rF   s    r,   r   zTestSetIndex.<lambda>  s    tAwwi r.   c                 ,    t          j        | g          S r   r   rK   r   s    r,   r   zTestSetIndex.<lambda>      j,aS11 r.   zappend, index_name)TNTr   TtestFNc                    |}||j         _         ||d                   }|t          k    rPd}t          j        t
          |          5  |                    |||           d d d            d S # 1 swxY w Y   d S t          |dd           }	|	t          |dd           gn|	}
|                    |||          }|                    dgd|          }|r|g|
n|
|j         _        t          j
        ||           d S )Nr   z%['one', 'two', 'three', 'one', 'two']r   r   rJ   r{   F)r<   r{   r   r   r   KeyErrorr:   getattrrJ   rL   rM   )r;   r-   r   r   
index_namer   r+   r   msgname_mir{   rN   rO   s                r,    test_set_index_pass_single_arrayz-TestSetIndex.test_set_index_pass_single_array  sY   $ !"c"S'll$;;9Cxs333 < <StF;;;< < < < < < < < < < < < < < < < < < c7D11G3:?GC..//D\\#D\@@F ||SEf|EEH:@#JJ#6#6#6dHN !&(33333s   A..A25A2c                 ,    t          j        | g          S r   r   r   s    r,   r   zTestSetIndex.<lambda>0  s    9OQRPS9T9T r.   )r   Tr   r   r   r   c                    |}||j         _        d ||d                   g}d|t          j        t          t
          t          fv rd ndg}|                    |||          }	|                    ddgd|          }
|r|
                    dd          n|
}
|r|g|n||
j         _	        t          j        |	|
           d S )Nr   r   r   Fr7   r   )r<   r{   r'   arrayr   r$   iterr:   r   rJ   rL   rM   )r;   r-   r   r   r   r   r+   r   rJ   rN   rO   s              r,   test_set_index_pass_arraysz'TestSetIndex.test_set_index_pass_arrays/  s     !"SSC\\"cbheT%BBBddLdf== <<c
v<FF15C8==1=---87=H
3U335
fh/////r.   box2c                 ,    t          j        | g          S r   r   r   s    r,   r   zTestSetIndex.<lambda>V  r   r.   c                     | j         S r   rz   r   s    r,   r   zTestSetIndex.<lambda>W      af r.   box1c                 ,    t          j        | g          S r   r   r   s    r,   r   zTestSetIndex.<lambda>b  r   r.   c                     | j         S r   rz   r   s    r,   r   zTestSetIndex.<lambda>c  r   r.   )r   r   r   r   c                 $   |}||j         _         ||d                    ||d                   g}|                    |||          }	 ||d                    ||d                   g}t          |d         t                    r5|d         dk    r)t          |d         t                    r|d         dk    rdn|}
|                    |d         g|
|          }|                    |d         g|d          }t          j        |	|           d S )Nr   r   r   r7   FT)r<   r{   r:   rp   strrL   rM   )r;   r-   r   r   r   r   r   r+   r   rN   
first_droprO   s               r,   $test_set_index_pass_arrays_duplicatez1TestSetIndex.test_set_index_pass_arrays_duplicateN  s"   > !"RWttBsG}}-df== RWttBsG}}- 47C(( GsNNtAw,, #GsNN E  	 <<a	
6<JJ%%tAwid4%HH
fh/////r.   r   c                     |}t          j        |d         |d         gddg          }|                    |||          }|                    ddgd|          }t          j        ||           d S )Nr   r   rI   r   F)r   rK   r:   rL   rM   )r;   r-   r   r   r+   r   rN   rO   s           r,   test_set_index_pass_multiindexz+TestSetIndex.test_set_index_pass_multiindex  s|     !%r#w3&8c
KKKdf== <<c
v<FF
fh/////r.   c                    t          t          d          dz  d          }t          t          j                            d                              d          |j        d          }|                    d          }t          j
        |j        |           t          t          j                            d                              d          |d          }|                    d          }t          j
        |j        |           |                                                    d          }t          j
        |j        |           d S )Nabr   r   rz   r   r@   rn   )r   r   r	   r'   r(   r)   r*   r^   r:   rL   r   r<   r}   )r;   cir+   rq   s       r,   (test_construction_with_categorical_indexz5TestSetIndex.test_construction_with_categorical_index  s   d4jj1n3777 )''**::2>>RYOO
 
 ll3
ci,,, RY22155EEbIIPRSSTTll3
ci,,, oo))#..
ci,,,,,r.   c                    t          g dg dt          t          d          t          d          d          t          t          d          t          d          d          d          }d	d
dd	gdd
gd	d
gfD ]Y}|                    |                                          }|                    |j                  }t          j        ||           Zd S )N)r7   r   r7   r7   r   )r@            "   abaabbacF)
categoriesorderedT)r   r   C1C2r   r   r   rG   )	r	   r   r   r:   r}   reindexrH   rL   rM   )r;   r+   colsrN   s       r,   )test_set_index_preserve_categorical_dtypez6TestSetIndex.test_set_index_preserve_categorical_dtype  s    $__)))!$w--DKKQVWWW!$w--DKKQUVVV	 
 
 4#tsDkD$<H 	. 	.D\\$''3355F^^BJ^77F!&"----	. 	.r.   c                 @   t          g dg dt          d          d          }t          |                    d          d          |_        |j                            d          |_        t          g d	d
          }|                    d                              d          }|                    dd          }t          j
        |j        j        d         |           t          j
        |j        j        d         t          ddgd
                     |j        j        ddgk    sJ |                    dd          }t          j
        |j        j        d         t          ddgd
                     t          j
        |j        j        d         |           |j        j        ddgk    sJ t          t          j                            d                              d                    }t          g dd          }t          g dd          }t%          ddd          }|                    d           }|                    |          }|                    |d          }|                    |d          }t          g d	d          }t          ddgd          }t          j
        |j        j        d         |           t          j
        |j        j        d         |           t          j
        |j        j        d         |           t          j
        |j                            d          |           t          j
        |j                            d          |           t          j
        |j                            d          |           d S )N)r   r   r   r   r   r   )2011-07-19 07:00:002011-07-19 08:00:002011-07-19 09:00:00r   r   r   r4   )r&   r   valuer   T)utcru   )r   r   r   rz   ra   r&   r   r   r7   r   r   r   z
US/Easternrb   )2012-04-01 09:00r   r   2012-04-02 09:00r   r   z2011-01-01 09:00z
Asia/Tokyo)rv   rc   r   r   )r	   ro   r   popr<   rd   r
   tz_localizer:   rL   r   levelsr   rJ   	swaplevelr'   r(   r)   r   r~   get_level_values)r;   r+   rO   idx1r   idx3	expected1	expected2s           r,   test_set_index_datetimez$TestSetIndex.test_set_index_datetime  s   777   q 
 
 rvvj11t<<<8&&|44 QQQ
 
 
 ''..99,GG\\'$\//
bhoa0(;;;
bhoa0%c
2Q2Q2QRRRx~*g!66666\\!Q
bhoa0%c
2Q2Q2QRRR
bhoa0(;;;x~':!66666ry,,Q//66q99::   

 

 

    

 

 

 ,aLIIIt$$\\$\\$t\,,\\$t\,,!QQQ
 
 
	 "!34
 
 
	 	bhoa0)<<<
bhoa0)<<<
bhoa0$777 	bh77::DAAA
bh77::DAAA
bh77::DAAAAAr.   c                 $   t          t          j                            d                              d                    }t	          ddd          }|                    |          }t	          ddd          }|                    |                              |          }t	          d	dd
          }|                    |          }|                    |d          }|                    |d          }t	          ddd          }t	          ddd          }t          j        |j	        j
        d         |           t          j        |j	        j
        d         |           t          j        |j	        j
        d         |           t          j        |j	                            d          |           t          j        |j	                            d          |           t          j        |j	                            d          |           d S )Nr   r4   z
2011-01-01r2   Mrv   rw   z2013-01-01 09:00rt   2005YTr   r   r7   )r	   r'   r(   r)   r   r   r:   rL   r   r<   r   r   )r;   r+   r   r   r   r   r  s          r,   test_set_index_periodz"TestSetIndex.test_set_index_period  s   ry,,Q//66q99::L!#>>>{{4  .DDD{{4  ''--FAC888\\$\\$t\,,\\$t\,, qsCCC	 !3QSIII	
bhoa0)<<<
bhoa0)<<<
bhoa0$777
bh77::DAAA
bh77::DAAA
bh77::DAAAAAr.   N)!__name__
__module____qualname__r=   rP   r[   r_   rg   rr   r   r   r   r   markparametrizer   r   r   r   r   r   r'   r   r   r   r   r   r   r   r   r   r  r  r   r.   r,   r0   r0   :   s       	 	 	0 0 0$	1 	1 	10 0 06 6 6	4 	4 	4( ( (&# # # I  I  IF [Vc3c
<T%UVV[Yu66[VdE]330 0 43 76 WV0( [Vc3c
<T%UVV[VdE]330 0 43 WV0 [Vc3c
<T%UVV[VdE]33	0 	0 43 WV	00 0 0 [H11	

 
 [XXX  [VdE]334 4 43 
 
48 [rx/T/TU  [OOO  [VdE]330 0 43	  0. [H11	
  [H11	
  [XXX  [VdE]330 0 43   80@ [Xe}55[VdE]33	0 	0 43 65	0- - -&. . .PB PB PBdB B B B Br.   r0   c                   x   e Zd Zd Zej                            dddg          ej                            dddg          d                         Zej                            dddg          ej                            dddg          d                         Zej                            de	e
ej        ed	 gg d
          ej                            dddgddg          ej                            dddg          ej                            dddg          d                                                 ZdS )TestSetIndexInvalidc                     |}d}t          j        t          d          5  t          j        t
          |          5  |                    dd           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        t          d          5  t          j        t
          |          5  |                    |d         |d         gd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nz5The 'verify_integrity' keyword in DataFrame.set_indexzIndex has duplicate keysr   r   T)verify_integrity)r   r   r   rL   assert_produces_warningr   r:   )r;   r-   r+   r   s       r,   test_set_index_verify_integrityz3TestSetIndexInvalid.test_set_index_verify_integrity%  s'    E]:-GHHH 	9 	9+N#FFF 9 9S48889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 ]:-GHHH 	H 	H+N#FFF H Hbgr#w/$GGGH H H H H H H H H H H H H H H	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hsj   A7A A7 A$	$A7'A$	(A77A;>A;D9&C+D+C/	/D2C/	3DD
Dr   TFr   c           	         |}t          j        t          d          5  |                    g d||           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    |d         |d         dg||           d d d            n# 1 swxY w Y   d}t          j        t          |          5  |                    t	          |d                   ||           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    d|d         t	          |d                   g||           d d d            d S # 1 swxY w Y   d S )	Nz['foo', 'bar', 'baz']r   )r   r   bazr   Xr   r   z%[('foo', 'foo', 'foo', 'bar', 'bar')])r   r   r   r:   r$   )r;   r-   r   r   r+   r   s         r,   test_set_index_raise_keysz-TestSetIndexInvalid.test_set_index_raise_keys1  s    !]8+BCCC 	J 	JLL...T&LIII	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J
 ]83/// 	L 	LLL"S'2c7C0tFLKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 6]83/// 	C 	CLLr#wd6LBBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C ]83/// 	S 	SLL#r#wbg7d6LRRR	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	SsG   AA	A	+(BB#&B#,C??DD%5E''E+.E+c           	         t           }|}d}t          j        t          |          5  |                     ||d                   ||           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    d|d          ||d                   g||           d d d            d S # 1 swxY w Y   d S )N,The parameter "keys" may be a column key, .*r   r   r   )setr   r   	TypeErrorr:   )r;   r-   r   r   r   r+   r   s          r,   test_set_index_raise_on_typez0TestSetIndexInvalid.test_set_index_raise_on_typeG  sp     <]9C000 	A 	ALLRWDL@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A ]9C000 	Q 	QLL#r#wBsG5DLPPP	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Q 	Qs#   (AA"A1B??CCr   c                 ,    t          j        | g          S r   r   r   s    r,   r   zTestSetIndexInvalid.<lambda>Y  s    *2H!2M2M r.   )r   r   znp.arrayr   r   )idslengthr3   r4   	too_shorttoo_longc                    |}t           j                            d                              dd|f          }d}t	          j        t          |          5  |                     ||          ||           d d d            n# 1 swxY w Y   t	          j        t          |          5  |                    d|j         ||          g||           d d d            d S # 1 swxY w Y   d S )Nr   r   r@   z<Length mismatch: Expected 5 rows, received array of length.*r   r   r   )	r'   r(   r)   integersr   r   r   r:   r   )	r;   r-   r   r  r   r   r+   r^   r   s	            r,   test_set_index_raise_on_lenz/TestSetIndexInvalid.test_set_index_raise_on_lenW  s    !&&q))221b6)DDL ]:S111 	@ 	@LLV4L???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ ]:S111 	M 	MLL#rtSS[[1VLLLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	Ms$   "BB
B)*C  C$'C$N)r	  r
  r  r  r   r  r  r  r  r   r   r'   r   r   r$  r   r.   r,   r  r  $  s       
H 
H 
H [Xe}55[VdE]33S S 43 65S( [Xe}55[VdE]33Q Q 43 65Q [	$(M(MNAAA   
 [X1vK3LMM[Xe}55[VdE]33M M 43 65 NM M M Mr.   r  c                   &    e Zd Zd Zd Zd Zd ZdS )TestSetIndexCustomLabelTypec                     G d d          } |dd          } |dd          }t          |ddg|d	d
gi          }t          |ddgit          d	d
g|                    }|                    |          }t          j        ||           |                    |g          }t          j        ||            |dd          }d}t          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    |g           d d d            d S # 1 swxY w Y   d S )Nc                   &    e Zd ZddZdefdZeZdS )KTestSetIndexCustomLabelType.test_set_index_custom_label_type.<locals>.ThingreturnNc                 "    || _         || _        d S r   r{   colorr;   r{   r-  s      r,   __init__zTTestSetIndexCustomLabelType.test_set_index_custom_label_type.<locals>.Thing.__init__w       	"


r.   c                     d| j         dS Nz<Thing >rz   r;   s    r,   __str__zSTestSetIndexCustomLabelType.test_set_index_custom_label_type.<locals>.Thing.__str__{      /////r.   r*  N)r	  r
  r  r/  r   r5  __repr__r   r.   r,   Thingr)  v  sD        # # # #0 0 0 0 0 HHHr.   r9  OneredTwobluer   r7   r   r2   rz   r|   Threepinkz<Thing 'Three'>r   )r	   r   r:   rL   rM   r   r   r   	r;   r9  thing1thing2r+   rO   rN   thing3r   s	            r,    test_set_index_custom_label_typez<TestSetIndexCustomLabelType.test_set_index_custom_label_types  s	   		 		 		 		 		 		 		 		 ue$$uf%%AA788fq!f-UAq65O5O5OPPP f%%
fh/// vh''
fh/// w'']83/// 	! 	!LL   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! ]83/// 	# 	#LL&"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s$   !DD
D)EEEc                     G d dt                     } |ddg          } |ddg          }t          |ddg|d	d
gi          }t          |ddgit          d	d
g|                    }|                    |          }t	          j        ||           |                    |g          }t	          j        ||            |ddg          }d}t          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    |g           d d d            d S # 1 swxY w Y   d S )Nc                       e Zd ZdefdZdS )XTestSetIndexCustomLabelType.test_set_index_custom_label_hashable_iterable.<locals>.Thingr*  c                 |    t          |           }d                    t          t          |                    }d| dS )Nz, zfrozenset({z}))sortedjoinr   repr)r;   tmpjoined_reprss      r,   r8  zaTestSetIndexCustomLabelType.test_set_index_custom_label_hashable_iterable.<locals>.Thing.__repr__  s7    Tll#yyT3887l7777r.   N)r	  r
  r  r   r8  r   r.   r,   r9  rG    s/        8# 8 8 8 8 8 8r.   r9  r:  r;  r<  r=  r   r7   r   r2   rz   r|   r>  r?  z frozenset\(\{'Three', 'pink'\}\)r   )		frozensetr	   r   r:   rL   rM   r   r   r   r@  s	            r,   -test_set_index_custom_label_hashable_iterablezITestSetIndexCustomLabelType.test_set_index_custom_label_hashable_iterable  s   	8 	8 	8 	8 	8I 	8 	8 	8 u~&&v''AA788fq!f-UAq65O5O5OPPP f%%
fh/// vh''
fh/// ())1]83/// 	! 	!LL   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! ]83/// 	# 	#LL&"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s$   *DDD2EEEc                     G d dt                     } |dd          } |dd          }t          ddgd	d
gg||g          }d}t          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    |g           d d d            d S # 1 swxY w Y   d S )Nc                   "    e Zd ZddZdefdZdS )RTestSetIndexCustomLabelType.test_set_index_custom_label_type_raises.<locals>.Thingr*  Nc                 "    || _         || _        d S r   r,  r.  s      r,   r/  z[TestSetIndexCustomLabelType.test_set_index_custom_label_type_raises.<locals>.Thing.__init__  r0  r.   c                     d| j         dS r2  rz   r4  s    r,   r5  zZTestSetIndexCustomLabelType.test_set_index_custom_label_type_raises.<locals>.Thing.__str__  r6  r.   r7  )r	  r
  r  r/  r   r5  r   r.   r,   r9  rR    sC        # # # #0 0 0 0 0 0 0r.   r9  r:  r;  r<  r=  r   r   r7   r2   rG   r  r   )r  r	   r   r   r  r:   )r;   r9  rA  rB  r+   r   s         r,   'test_set_index_custom_label_type_raiseszCTestSetIndexCustomLabelType.test_set_index_custom_label_type_raises  s   	0 	0 	0 	0 	0C 	0 	0 	0 ue$$uf%%AA'&&1ABBB<]9C000 	! 	!LL   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! ]9C000 	# 	#LL&"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s$   "BBB*CCCc                    t          t          j                            d                              d                    }t	          ddd          }t	          ddd          }|                    |          }t          j        |j        |           |                    |          }t          j        |j        |           d S )Nr   r4   z
2011/01/01r  r  2013r  )	r	   r'   r(   r)   r   r:   rL   r   r<   )r;   r+   r   r   s       r,   test_set_index_periodindexz6TestSetIndexCustomLabelType.test_set_index_periodindex  s    ry,,Q//66q99::L!#>>>FAC888\\$
bh---\\$
bh-----r.   N)r	  r
  r  rD  rO  rU  rX  r   r.   r,   r&  r&  r  sR        $# $# $#L%# %# %#N# # #4	. 	. 	. 	. 	.r.   r&  )__doc__r   r   numpyr'   r   pandas.errorsr   pandasr   r   r	   r
   r   r   r   r   r   r   pandas._testing_testingrL   fixturer-   r0   r  r&  r   r.   r,   <module>r`     s          
      ( ( ( ( ( (                                6gB gB gB gB gB gB gB gBTKM KM KM KM KM KM KM KM\q. q. q. q. q. q. q. q. q. q.r.   