
    Egg                         d Z ddlmZmZ ddlZddl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)
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    ^/var/www/sysmax/venv/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   )r6   r   tuples)r   r   from_tuples	set_index)selfr   r*   r7   indexs        r+   test_set_index_multiindexz&TestSetIndex.test_set_index_multiindex9   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 )Nr6   r   )r   pr   
   )r   mr1         )r   r@   r>   r2         )r   r@   r>   xcolumnsr   rE   r@   r>   names)r   r9   r   from_arraysr;   tmassert_frame_equal)r:   r*   resultexpecteds       r+   test_set_index_empty_columnz(TestSetIndex.test_set_index_empty_columnD   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   r9   r;   to_framedtypesrK   assert_series_equal)r:   df1df2rM   rN   s        r+   test_set_index_empty_dataframez+TestSetIndex.test_set_index_empty_dataframeV   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   r6   )r   r   )r   r6   r   )r1   r1   rF   r   r6   )r   r8   r   r&   r'   r(   r)   r9   rG   ilocvaluesr;   rI   rK   rL   )r:   rG   r*   rM   rN   s        r+    test_set_index_multiindexcolumnsz-TestSetIndex.test_set_index_multiindexcolumnsa   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   rA   )r	   
tz_convertr   r9   r;   hourr   r   )r:   idxr*   s      r+   test_set_index_timezonez$TestSetIndex.test_set_index_timezonen   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  r6   r   .0is     r+   
<listcomp>zBTestSetIndex.test_set_index_cast_datetimeindex.<locals>.<listcomp>z   s/    OOOahtQ**Yq\\9OOOr-   i  r   r   r   r   )
r   ranger&   r'   r(   r)   r9   
isinstancer;   r	   )r:   r*   idfs      r+   !test_set_index_cast_datetimeindexz.TestSetIndex.test_set_index_cast_datetimeindexw   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:00r1   h
US/Pacific)periodsfreqrb   r   r6   r   )r1   r2   r   )r   r   )datar;   r;   namer   rH   r   r;   )r   r   reset_indexr9   r
   r;   
_with_freqrK   rL   r   rJ   )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                 z   |}t          t          j        t          |                    d d d                   }|                    |          }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 )NzLength mismatchmatchr   )r
   r&   arangelenr9   rK   assert_index_equalr;   pytestraises
ValueError)r:   float_string_framer*   re   s       r+   test_set_indexzTestSetIndex.test_set_index   s    BIc"gg&&ttt,--\\#
bh,,,]:->??? 	# 	#LLSSqS"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   B00B47B4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?   r2   ABCDrQ   c                     g | ]}d | S )zi- ri   s     r+   rl   z5TestSetIndex.test_set_index_names.<locals>.<listcomp>   s    555aa555r-   r?   )rG   r;   rz   r   r   rH   )r   r   r   r   )r   r   r   r    r   r    )r   r&   onesr
   listobjectrn   r;   rz   r9   rI   r   rJ   Tr]   ro   rK   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   rj   rE   r*   s     r+   rl   z<TestSetIndex.test_set_index_drop_inplace.<locals>.<listcomp>   s    )>)>)>A"Q%)>)>)>r-   rH   ry   r6   axisT)r   r   )r   )ro   r   r   rJ   r
   r   r;   copyr9   rK   rL   )
r:   r,   r   r   r   re   rN   rM   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|z             }|r                    |d          n                                }||_                            ||d          }t          j	        ||           d S )Nc                      g | ]
}|         S r   r   r   s     r+   rl   z6TestSetIndex.test_set_index_append.<locals>.<listcomp>   s    ...A"Q%...r-   rH   r6   r   Tr   append)
ro   r   r   rJ   r;   r   r   r9   rK   rL   )r:   r,   r   r   re   rN   rM   r*   s          @r+   test_set_index_appendz"TestSetIndex.test_set_index_append   s     !!$--9ttD6$XJ........tftm
 
 
 -1?2774a7(((bggiidd;;
fh/////r-   c                     |                     dg|d          }t          |t                    r|n|g}|                     dg|z   |d          }|                     ||d          }t          j        ||           d S )Nr    Tr   )r9   ro   r   rK   rL   )r:   r,   r   r   r*   rN   rM   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 )Nrw   rT   )valkeyr   r6   r   r   r   r   ry   c                     | dk    S )Nr6   r   )indxs    r+   <lambda>z<TestSetIndex.test_set_index_after_mutation.<locals>.<lambda>   s
    tqy r-   )r   r
   locr;   mapr9   rK   rL   )r:   r*   rN   rY   rM   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   rE   s    r+   r   zTestSetIndex.<lambda>	  s    tAwwi r-   c                 ,    t          j        | g          S r   r   rJ   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|
z   n|
|j         _        t          j
        ||           d S )Nr   z%['one', 'two', 'three', 'one', 'two']r   r   rI   rz   F)r;   rz   r   r   r   KeyErrorr9   getattrrI   rK   rL   )r:   r,   r   r   
index_namer   r*   r   msgname_mirz   rM   rN   s                r+    test_set_index_pass_single_arrayz-TestSetIndex.test_set_index_pass_single_array  sX   $ !"c"S'll$;;9Cxs333 < <StF;;;< < < < < < < < < < < < < < < < < < c7D11G3:?GC..//D\\#D\@@F ||SEf|EEH:@#JJ<$#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>.  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|z   n||
j         _	        t          j        |	|
           d S )Nr   r   r   Fr6   r   )r;   rz   r&   arrayr   r#   iterr9   r   rI   rK   rL   )r:   r,   r   r   r   r   r*   r   rI   rM   rN   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
|e335
fh/////r-   box2c                 ,    t          j        | g          S r   r   r   s    r+   r   zTestSetIndex.<lambda>T  r   r-   c                     | j         S r   ry   r   s    r+   r   zTestSetIndex.<lambda>U      af r-   box1c                 ,    t          j        | g          S r   r   r   s    r+   r   zTestSetIndex.<lambda>`  r   r-   c                     | j         S r   ry   r   s    r+   r   zTestSetIndex.<lambda>a  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   r6   FT)r;   rz   r9   ro   strrK   rL   )r:   r,   r   r   r   r   r   r*   r   rM   
first_droprN   s               r+   $test_set_index_pass_arrays_duplicatez1TestSetIndex.test_set_index_pass_arrays_duplicateL  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   rH   r   F)r   rJ   r9   rK   rL   )r:   r,   r   r   r*   r   rM   rN   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   ry   r   r?   rm   )r   r   r   r&   r'   r(   r)   r]   r9   rK   r   r;   r|   )r:   cir*   rp   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)r6   r   r6   r6   r   )r?            "   abaabbacF)
categoriesorderedT)r   r   C1C2r   r   r   rF   )	r   r   r   r9   r|   reindexrG   rK   rL   )r:   r*   colsrM   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   r3   )r%   r   valuer   T)utcrt   )r   r   r   ry   r`   r%   r   r   r6   r   r   r   z
US/Easternra   )2012-04-01 09:00r   r   2012-04-02 09:00r   r   z2011-01-01 09:00z
Asia/Tokyo)ru   rb   r   r   )r   rn   r   popr;   rc   r	   tz_localizer9   rK   r   levelsr
   rI   	swaplevelr&   r'   r(   r   r}   get_level_values)r:   r*   rN   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   r3   z
2011-01-01r1   Mru   rv   z2013-01-01 09:00rs   2005YTr   r   r6   )r   r&   r'   r(   r   r   r9   rK   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<   rO   rZ   r^   rf   rq   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+   r/   r/   8   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-   r/   c                      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          ej                            deg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                 P   |}t          j        t          d          5  |                    dd           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    |d         |d         gd           d d d            d S # 1 swxY w Y   d S )NzIndex has duplicate keysr   r   T)verify_integrity)r   r   r   r9   )r:   r,   r*   s      r+   test_set_index_verify_integrityz3TestSetIndexInvalid.test_set_index_verify_integrity#  s;    ]:-GHHH 	5 	5LLtL444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 ]:-GHHH 	D 	DLL"S'2c7+dLCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds#   AA	A(&BB"B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   r9   r#   )r:   r,   r   r   r*   r   s         r+   test_set_index_raise_keysz-TestSetIndexInvalid.test_set_index_raise_keys,  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+r   set)idsc           	         |}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   )r   r   	TypeErrorr9   )r:   r,   r   r   r   r*   r   s          r+   test_set_index_raise_on_typez0TestSetIndexInvalid.test_set_index_raise_on_typeB  sk    !<]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:1B88B<?B<c                 ,    t          j        | g          S r   r   r   s    r+   r   zTestSetIndexInvalid.<lambda>T  s    *2H!2M2M r-   )r   r
   znp.arrayr   r   lengthr2   r3   	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   r9   r   )	r:   r,   r   r  r   r   r*   r]   r   s	            r+   test_set_index_raise_on_lenz/TestSetIndexInvalid.test_set_index_raise_on_lenR  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  r  "  s       D D D [Xe}55[VdE]33S S 43 65S( [Xe}55[VdE]33[USEw77
Q 
Q 87 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   rz   colorr:   rz   r+  s      r+   __init__zTTestSetIndexCustomLabelType.test_set_index_custom_label_type.<locals>.Thing.__init__r       	"


r-   c                 2    dt          | j                   dS Nz<Thing >reprrz   r:   s    r+   __str__zSTestSetIndexCustomLabelType.test_set_index_custom_label_type.<locals>.Thing.__str__v      3di3333r-   r(  N)r  r	  r
  r-  r   r5  __repr__r   r-   r+   Thingr'  q  sD        # # # #4 4 4 4 4 HHHr-   r9  OneredTwobluer   r6   r   r1   ry   r{   Threepinkz<Thing 'Three'>r   )r   r
   r9   rK   rL   r   r   r   	r:   r9  thing1thing2r*   rN   rM   thing3r   s	            r+    test_set_index_custom_label_typez<TestSetIndexCustomLabelType.test_set_index_custom_label_typen  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   r3  )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   r6   r   r1   ry   r{   r>  r?  z frozenset\(\{'Three', 'pink'\}\)r   )		frozensetr   r
   r9   rK   rL   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__  r.  r-   c                 2    dt          | j                   dS r0  r2  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  rQ    sC        # # # #4 4 4 4 4 4 4r-   r9  r:  r;  r<  r=  r   r   r6   r1   rF   r  r   )r  r   r   r   r  r9   )r:   r9  rA  rB  r*   r   s         r+   'test_set_index_custom_label_type_raiseszCTestSetIndexCustomLabelType.test_set_index_custom_label_type_raises  s   	4 	4 	4 	4 	4C 	4 	4 	4 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   r3   z
2011/01/01r  r  2013r  )	r   r&   r'   r(   r   r9   rK   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  rN  rT  rW  r   r-   r+   r$  r$  m  sR        $# $# $#L%# %# %#N# # #4	. 	. 	. 	. 	.r-   r$  )__doc__r   r   numpyr&   r   pandasr   r   r   r	   r
   r   r   r   r   r   pandas._testing_testingrK   fixturer,   r/   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HM HM HM HM HM HM HM HMVq. q. q. q. q. q. q. q. q. q.r-   