
    Pik                        d dl mZm Z mZmZ d dlZd dlZd dlmZ	 d dl
mZ d dlmZ d dlmc mZ d dlZd dlmZmZmZmZmZmZ d dlmZ d dlmZ  e dd	d	           e d
d	d	          cZZ  G d d          Z! G d d          Z" G d d          Z# G d d          Z$ G d d          Z% G d d          Z& G d d          Z' G d d          Z( G d d          Z)dS )    )datedatetimetime	timedeltaNindex)np_long)Pandas4Warning)DatetimeIndexIndex	Timestampbdate_range
date_rangenotna)	to_offseti       c                       e Zd Zd Zej                            dddg          d             Zej                            dddg          d	             Zej                            dddg          d
             Z	d Z
dS )TestGetItemc                     t          dd          }t          dd          }t          ||dd          }|dd          j        |j        k    sJ d S )	Nz2013-07-01 00:00:00zAmerica/Los_Angelestzz2013-07-02 00:00:00h
timebucketfreqnamer   )r   r   r   )selfstetdrs       /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/indexes/datetimes/test_indexing.pytest_getitem_slice_keeps_namez)TestGetItem.test_getitem_slice_keeps_name!   sc    ,1FGGG,1FGGGBS|<<<!""v{bg%%%%%%    r   N
Asia/Tokyoc                    t          ddd|d          }|d         }|t          d|j                  k    sJ |dd         }t          dd	d|j        d          }t          j        ||           |j        |j        k    sJ |dd
d         }t          ddd|j        d          }t          j        ||           |j        |j        k    sJ |ddd         }t          ddd|j        d          }t          j        ||           |j        |j        k    sJ |dd d         }t          g d|j        dd          }t          j        ||           |j        |j        k    sJ d S )N
2011-01-01
2011-01-31Didxr   r   r   r   r      
2011-01-05
      z
2011-01-092Di   z
2011-01-12z
2011-01-243D   )r-   
2011-01-04
2011-01-03
2011-01-02r'   z-1Ddtyper   r   )r   r   r   tmassert_index_equalr   r   r:   r   r   r*   resultexpecteds        r"   test_getitemzTestGetItem.test_getitem(   s   |#"5QQQQ<CF;;;;;;;QqS,SSV%
 
 
 	fh///{hm++++Qr!V,Tcf5
 
 
 	fh///{hm++++SAX,Tcf5
 
 
 	fh///{hm++++QUU RRR)	
 
 
 	fh///{hm++++++r$   r   BCc                 @   t          t          t          |          }|d d         }t          |                    t
          j                  d d         |          }t          j        ||           |j	        |j	        k    sJ |j	        |j	        k    sJ |d d d         }|j	        t          |          dz  k    sJ |g d         }t          |          dk    sJ t          |t                    sJ |j	        J |d         |t          d                   k    sJ d S )Nr   r,   )r4   r2   r/   r   r   r4   )r   STARTENDr   viewnpndarrayr;   r<   r   r   len
isinstancer	   )r   r   rngsmallerexpslicedfancy_indexeds          r"   test_dti_business_getitemz%TestGetItem.test_dti_business_getitemN   s)   %4000bqb'CHHRZ00!44@@@
gs+++|sx''''|sx''''SSqS{ioo11111OOO,=!!Q&&&&-77777!))) 1vWQZZ((((((r$   c                     t          t          t          |          }t          j        t
          d          5  |d d d f          d d d            d S # 1 swxY w Y   d S )NrD   zMulti-dimensional indexingmatch)r   rE   rF   pytestraises
ValueError)r   r   rL   s      r"   /test_dti_business_getitem_matplotlib_hackaroundz;TestGetItem.test_dti_business_getitem_matplotlib_hackaroundb   s    %4000]:-IJJJ 	 	4LL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAc                     t          ddd          }|g d         }|d         }|d         }|d         }|t          d	          k    sJ |t          d
          k    sJ |t          d          k    sJ |j        J d S )Nz1/1/2005z	12/1/2005ME)startendr   )r   r2   r,   r   r   r/   z	2/28/2005z	4/30/2005z	6/30/2005)r   r   r   )r   dtidti2v1v2v3s         r"   test_getitem_int_listz!TestGetItem.test_getitem_int_listi   s    z{FFF999~!W!W!WY{++++++Y{++++++Y{++++++ y     r$   )__name__
__module____qualname__r#   rU   markparametrizer@   rQ   rX   rb    r$   r"   r   r       s        & & & [TD,#788#, #, 98#,J [Vc3Z00) ) 10)& [Vc3Z00  10! ! ! ! !r$   r   c                   x    e Zd Zej                            dddg          d             Zd Zd Zd Z	d Z
d	 Zd
S )	TestWhereis_tdTFc                    t          ddd          }|r||d         z
  }t          t          j        t          j        g|dd                                                    }|                    t          |          |          }|j        J d S )N20130101r2   
US/Easternperiodsr   r   r/   )r   r   pdNaTtolistwherer   r   )r   rk   r   otherr>   s        r"   test_where_freq_invalidationz&TestWhere.test_where_freq_invalidationz   s     :q\BBB 	%E!H$Ervrv;abb	(8(8(:(:;<<U5\\511{"""""r$   c                     t          dddd          }g d}t          |d         |d         |d         gd d	          }|                    ||d d d
                   }t          j        ||           d S )Nrm   r2   r)   r*   )rp   r   r   )TTFr   r   r   r5   )r   r   rt   r;   r<   )r   r]   condr?   r>   s        r"   test_where_doesnt_retain_freqz'TestWhere.test_where_doesnt_retain_freq   s    QSuEEE""" #a&#a&#a&!95QQQ4TTrT++
fh/////r$   c                    t          ddd          }t          j        t          j        fD ]=}|                    t          |          |          }|}t          j        ||           >|	                                }t          t          j        t          j        g|dd                                                    }|                    t          |          |          }t          j        ||           |	                                }t          t          j        t          j        g|dd                                                    }|                    t          |          |j                  }t          j        ||           d S )Nrm   r2   rn   ro   )ru   r/   )r   rH   nanrq   rr   rt   r   r;   r<   copyr   rs   _values)r   iarrr>   r?   i2s         r"   test_where_otherzTestWhere.test_where_other   s4   z1>>>FBF# 	4 	4CWWU1XXSW11FH!&(3333VVXXBFBF4QqrrU\\^^455rB''
fb)))VVXXBFBF4QqrrU\\^^455rBJ//
fb)))))r$   c                    t          dddd          }|dd                                          }t          t          j        t          j        g|          }t          |          }|                    ||j                  }t          t          j        j        t          j        j        g|t                    }t          j        ||           |                    d           }|                    ||          }t          |d         |d	         g|dd                                          t                    }t          j        ||           |                    d                               d
          }|                    ||          }t          |d         |d	         g|t                    }t          j        ||           |j                            d          }	|                    ||	          }t          |	d         |	d	         g|t                    }t!          |d         t"          j                  sJ t          j        ||           |                    ||j                  }t          t          j        j        t          j        j        g|t                    }t!          |d         t(                    sJ t          j        ||           t          j        d          }
|                    ||
          }t          |
|
g|t                    }|d         |
u sJ t          j        ||           d S )Nrm   r2   rn   ns)rp   r   unitr/   r:   r   r   r)   ztimedelta64[ns]r4   )days)r   rs   r   rq   rr   r   rt   valuesasm8objectr;   r<   tz_localize	to_periodasi8rG   rK   rH   timedelta64_valueint	Timedelta)r   r]   tailr   maskr>   r?   naivepitdatds              r"   test_where_invalid_dtypesz#TestWhere.test_where_invalid_dtypes   s   Q<dKKK122w~~BFBF*T*++Ryy 4++"&+rv{:T:&III
fh/// %%T2&&"Q%A<qrr)9)9););<FKKK
fh///^^D!!++C004$$"Q%A..f===
fh///gll,--4%%#a&#a&040???(1+r~66666
fh///4))"&->>fMMM(1+s+++++
fh/// \q!!!4$$"b4777{b    
fh/////r$   c                 <   |}t          dd|          }t          j        g d          }t          j        dd          }t	          |d         ||d         gt
          	          }|d
         |u sJ |                    ||          }t          j        ||           d S )Nz
2013-01-01r2   ro   )TFTrr   r   r   r/   r   r   )	r   rH   arrayr   r   r   rt   r;   r<   )r   tz_aware_fixturer   r]   rx   tdnatr?   r>   s           r"   test_where_mismatched_natz#TestWhere.test_where_mismatched_nat   s    qR888x+++,,ud++#a&%Q0???{e####4''
fh/////r$   c                    t          ddd          }|                    t          |                    }|}t          j        ||           |                                }t          t          j        t          j        g|dd          	                                          }|                    t          |                    }|}t          j        ||           d S )Nrm   r2   rn   ro   r/   )
r   rt   r   r;   r<   r|   r   rq   rr   rs   )r   r~   r>   r?   r   s        r"   test_where_tzzTestWhere.test_where_tz   s    z1>>>q""
fh///VVXXBFBF4QqrrU\\^^455r##
fh/////r$   N)rc   rd   re   rU   rf   rg   rv   ry   r   r   r   r   rh   r$   r"   rj   rj   y   s        [WtUm44# # 54#0 0 0* * *&(0 (0 (0T
0 
0 
0
0 
0 
0 
0 
0r$   rj   c                   
   e Zd Zej                            dddg          d             Zd Zej                            dddg          d	             Zd
 Z	ej                            dg d          d             Z
d Zd ZdS )TestTaketzstrrn   zdateutil/US/Easternc                     t          dd|          }|                    t          d                    }|j        |j        k    sJ |j        |j        k    sJ d S )N1/1/2000   ro   r,   )r   takeranger   r   )r   r   rL   r>   s       r"   test_dti_take_dont_lose_metaz%TestTake.test_dti_take_dont_lose_meta   s]    RE:::%((##yCF""""{ch&&&&&&r$   c                    t          t          j        t          d          t          d          g          }|                    g d          }t          |d         |d         |d         g          }t          j        ||           d S )Nrm   20130102r5   r   r   r5   r   r   )r   rq   rr   r   r   r;   r<   )r   r   r>   r?   s       r"   test_take_nan_first_datetimez%TestTake.test_take_nan_first_datetime   sv    rvy'<'<i
>S>STUUJJJ'' %)U1XuQx!@AA
fh/////r$   r   Nr%   c                    t          dddd|          }|                    dg          }|t          d|j                  k    sJ |                    g d          }t          dd	d|j        d
          }t	          j        ||           |j        |j        k    sJ |                    g d          }t          ddd|j        d
          }t	          j        ||           |j        |j        k    sJ |                    g d          }t          ddd|j        d
          }t	          j        ||           |j        |j        k    sJ |                    g d          }t          g d|j        d d          }t	          j        ||           |j        J |                    g d          }t          g d|j        d d          }t	          j        ||           |j        J d S )Nr'   r(   r)   r*   )r   r   r   r   r   r   r   r/   r7   r+   )r   r/   r4   r-   r0   )   r4   r   z
2011-01-08r8   z-3D)r2   r/   r,   )r6   r7   
2011-01-06r9   )r/   r,   )z
2011-01-29r7   r   )	r   r   r   r   r;   r<   r   r   r:   r=   s        r"   	test_takezTestTake.test_take   s3    |#EbQQQ1#<CF;;;;;;;)))$$,SSV%
 
 
 	fh///{hm++++)))$$,Tcf5
 
 
 	fh///{hm++++)))$$,UsvE
 
 
 	fh///{hm++++)))$$ 666)	
 
 
 	fh///{"""***%% 666)	
 
 
 	fh///{"""""r$   c                    t          dddd          }g d}d}t          j        t          |          5  |                    |d	
           d d d            n# 1 swxY w Y   d}t          j        t
          |          5  |                    ||           d d d            n# 1 swxY w Y   d}t          j        t
          |          5  |                    |d           d d d            d S # 1 swxY w Y   d S )Nr'   r(   r)   r*   r   )r      r,   	   r.         r2   z1take\(\) got an unexpected keyword argument 'foo'rS   r/   )fooz$the 'out' parameter is not supported)outz%the 'mode' parameter is not supportedclip)mode)r   rU   rV   	TypeErrorr   rW   )r   r*   indicesmsgs       r"   test_take_invalid_kwargsz!TestTake.test_take_invalid_kwargs#  s   |#EJJJ---B]9C000 	% 	%HHW!H$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 5]:S111 	+ 	+HHW'H***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 6]:S111 	+ 	+HHW6H***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s5   AA AB%%B),B)C22C69C6)Nrn   r%   c           	         t          dddd          t          dddd          t          dddd          t          dddd          g}t          ddd	|d
          }t          |d d
|j                  }|                    g d          }|g d         }||fD ][}t          j        ||           t          |t                    sJ |j        J |j	        |j	        k    sJ |j
        |j
        k    sJ \d S )Nr   r      r         z2010-01-01 09:00z2010-02-01 09:00r   r*   )r[   r\   r   r   r   )r   r   r:   )r,   r         )r   r   r   r:   r   r;   r<   rK   r   r   r   )r   r   datesr*   r?   taken1taken2takens           r"   
test_take2zTestTake.test_take24  s3    T1a$$T1a$$T1a$$T1a$$	
 $"
 
 
 !TSYOOO---((]]]#f% 	/ 	/E!%222e]33333:%%%8x{****:.....	/ 	/r$   c                 V   t          g dd          }|                    t          j        g d                    }t          g dd          }t	          j        ||           |                    t          j        g d          d          }t          g dd          }t	          j        ||           |                    t          j        g d          d	d
          }t          g dd          }t	          j        ||           d}t          j        t          |          5  |                    t          j        g d          d           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    t          j        g d          d           d d d            n# 1 swxY w Y   d}t          j        t          |          5  |                    t          j        ddg                     d d d            d S # 1 swxY w Y   d S )Nr'   
2011-02-01
2011-03-01xxx)r   r   r   r5   r   r'   r   T
fill_valuer   r'   rr   F
allow_fillr   JWhen allow_fill=True and fill_value is not None, all indices must be >= -1rS   r   r   r   r   r1   out of boundsr   r1   
r   r   rH   r   r;   r<   rU   rV   rW   
IndexErrorr   r*   r>   r?   r   s        r"   test_take_fill_valuezTestTake.test_take_fill_valueP  s   FFFUSSS"(:::..// !K!K!KRWXXX
fh/// "(:::..4@@ !D!D!D5QQQ
fh/// "(:::..5TRR !K!K!KRWXXX
fh/// Y 	 ]:S111 	< 	<HHRXjjj))dH;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<]:S111 	< 	<HHRXjjj))dH;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< ]:S111 	( 	(HHRXq"g&&'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s6   ),E!!E%(E%,F??GG'*HH"%H"c                 ^   t          g ddd          }|                    t          j        g d                    }t          g ddd          }t	          j        ||           |                    t          j        g d          d          }t          g d	dd          }t	          j        ||           |                    t          j        g d          d
d          }t          g ddd          }t	          j        ||           d}t          j        t          |          5  |                    t          j        g d          d           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    t          j        g d          d           d d d            n# 1 swxY w Y   d}t          j        t          |          5  |                    t          j        ddg                     d d d            d S # 1 swxY w Y   d S )Nr   r   rn   )r   r   r   r   Tr   r   Fr   r   rS   r   r   r   r   r1   r   r   s        r"   "test_take_fill_value_with_timezonez+TestTake.test_take_fill_value_with_timezonem  s   666U|
 
 
 "(:::..// 666U|
 
 
 	fh/// "(:::..4@@ ///e
 
 
 	fh/// "(:::..5TRR 666U|
 
 
 	fh/// Y 	 ]:S111 	< 	<HHRXjjj))dH;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<]:S111 	< 	<HHRXjjj))dH;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< ]:S111 	( 	(HHRXq"g&&'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s6   -,E%%E),E),GG
G+*H""H&)H&)rc   rd   re   rU   rf   rg   r   r   r   r   r   r   r   rh   r$   r"   r   r      s        [W|5J&KLL' ' ML'0 0 0 [TD,#788.# .# 98.#`+ + +" [T#E#E#EFF/ / GF/6( ( (:"( "( "( "( "(r$   r   c                      e Zd Zd Zd Zd Zej                            dddg          d             Z	d Z
d	 Zej                            d
 ej        d           ej        d           ed          g          d             Zd Zd ZdS )
TestGetLocc                     t          dd          }|d                             d          }|                    |          }|dk    sJ ||v sJ d S )N
2000-01-01r2   rp   r   ms)r   as_unitget_loc)r   r*   keylocs       r"   test_get_loc_key_unit_mismatchz)TestGetLoc.test_get_loc_key_unit_mismatch  sX    q111!fnnT""kk#axxxxczzzzzzr$   c                 r   t          dd          j                            d          }t          |          }|d                             d          t          j        d          z   }t          j        t          d	          5  |
                    |           d d d            n# 1 swxY w Y   ||vsJ d S )
Nr   r2   r   zM8[s]r   r   r   z,Timestamp\('2000-01-01 00:00:00.000000001'\)rS   )r   _dataastyper   r   rq   r   rU   rV   KeyErrorr   )r   dtar]   r   s       r"   +test_get_loc_key_unit_mismatch_not_castablez6TestGetLoc.test_get_loc_key_unit_mismatch_not_castable  s    q1117>>wGGC  !fnnT""R\!__4]K
 
 
 	 	 KK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 #~~~~~~s   B&&B*-B*c                 b   t          ddd          }|                    t          d                    }t          j        dg          }t          j        ||d           |                    t          dd                    }t          j        g           }t          j        ||d           d S )	Nr      r   rp   r   r   F)check_dtype   )r   r   r   rH   r   r;   assert_numpy_array_equalr   r*   r>   r?   s       r"   test_get_loc_time_objz TestGetLoc.test_get_loc_time_obj  s    r<<<T"XX&&8RD>>
#FH%HHHHT"b\\**8B<<
#FH%HHHHHHr$   offsetr.   c                 h   d}||z   }t          ddd          }|j        dz  |j        dz  z   |j        z   }d}|                                5  |                    t          d|           t          d	|d
          }t          j	        t          j                            d                              |          |          }	t          j        |||t          j                  }
|	j                            |          }t%          j        ||
           t%          j        |	|         |	j        |
                    |	                                |	                                }}||xx         dz  cc<   |j        |
xx         dz  cc<   t%          j        ||           d d d            d S # 1 swxY w Y   d S )N2   r      r   i  <   iQ _SIZE_CUTOFFz
2014-11-26sr   r/   r   r   r   )r   hourminutesecondcontextsetattrlibindexr   rq   SeriesrH   randomdefault_rngstandard_normalarangeintpr   r   r;   r   assert_series_equalilocr|   )r   monkeypatchr   size_cutoffnr   r[   stepr*   tslocsr>   leftrights                 r"   test_get_loc_time_obj2z!TestGetLoc.test_get_loc_time_obj2  s    & 2r24#*r/1CJ>  "" 	0 	0.+FFF\13???C290033CCAFFcRRRB9UAt27;;;DX%%c**F'555"2c7BGDM:::''))RWWYY%DIIIIIIJt#"4///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s   EF''F+.F+c                     t          ddd          }t          t          j        g          }|                    |          }t          j        g t
          j                  }t          j	        ||           d S )Nr   +   iH7 )r  r  microsecondr   )
r   r   rq   rr   r   rH   r   r  r;   r   )r   ticr]   r   r?   s        r"   test_get_loc_time_natz TestGetLoc.test_get_loc_time_nat  si     "RV<<<RVH%%kk#8Bbg...
#C22222r$   c                 L   t          ddg          }|                    t          j                  dk    sJ |                    d           dk    sJ |                    t          j                  dk    sJ |                    t          j                  dk    sJ |                    t	          j        d                    dk    sJ t          j	        t          d          5  |                    t	          j        d                     d d d            d S # 1 swxY w Y   d S )N1/3/2000rr   r   rS   )r   r   rq   rr   rH   r{   NA
datetime64rU   rV   r   r   r   r   s     r"   test_get_loc_natzTestGetLoc.test_get_loc_nat  sJ   z5122}}RV$$))))}}T""a''''}}RV$$))))}}RU##q((((}}R]51122a7777]85111 	1 	1MM".//000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   $(DD Dr   r   r   c                     t          dd          }d}t          j        t          |          5  |                    |           d d d            d S # 1 swxY w Y   d S )Nz
1970-01-01r.   r   z,Cannot index DatetimeIndex with [Tt]imedeltarS   )r   rU   rV   r   r   )r   r   r]   r   s       r"   "test_get_loc_timedelta_invalid_keyz-TestGetLoc.test_get_loc_timedelta_invalid_key  s     r222<]9C000 	 	KK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAc                     t          dg          }t          j        t          d          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr  2000rS   r   )r   rU   rV   r   r   r"  s     r"   !test_get_loc_reasonable_key_errorz,TestGetLoc.test_get_loc_reasonable_key_error  s    zl++]86222 	& 	&MM*%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   AAAc                     t          dd          }|                    d          }t          dd          }||k    sJ d S )Nr   z1/1/20102009i  iE  )r   r   slicer   rL   r>   r?   s       r"   test_get_loc_year_strz TestGetLoc.test_get_loc_year_str  sH    Z00V$$t$$!!!!!!r$   N)rc   rd   re   r   r   r   rU   rf   rg   r  r  r#  rq   r   r   r%  r(  r-  rh   r$   r"   r   r     s         
 
 

I 
I 
I [XRy110 0 210.3 3 31 1 1  [U\R\!__lbl1ooyyQR||$TUU  VU& & &" " " " "r$   r   c            	       z    e Zd Zd Zej                            dg dg dg dg dg dg          d             Zd	S )
TestContainsc                 Z    t          ddddd          }t          ||g          }||v sJ d S )Ni  r   r,   r   r   )r   r   )r   dixs      r"   !test_dti_contains_with_duplicatesz.TestContains.test_dti_contains_with_duplicates  s9    T2q"b))Aq6""Bwwwwwwr$   vals)r   r   r   )r   r   r5   )r   r5   r5   )2015r5  2016)r5  r5  2014c                 <    t          |          }|d         |v sJ d S )Nr   )r   )r   r4  r*   s      r"   test_contains_nonuniquez$TestContains.test_contains_nonunique   s&     D!!1v}}}}}}r$   N)rc   rd   re   r3  rU   rf   rg   r9  rh   r$   r"   r/  r/    s          
 [IIJJKK$$$$$$	
	 	 	 	  r$   r/  c                   *   e Zd Z ej        d          ej                            dddg          d                         Zd Z	d Z
ej                            d ed	d
d
           ed          g ed           ed	d
d          gg          d             Zej                            d edd
d
           ed          gddgf ed           edd
d
          gddgf edd
d
           edd
d
          gddgfg          d             Zd ZdS )TestGetIndexerpyarrowas_tdTFc                    t          dd          }|                    d          d d d         }|r||d         z
  }||d         z
  }|                    |          }t          j        g dt          j                  }t          j        ||           |                    |          }t          j        ||           d S )	Nz
2016-01-01r2   r   ztimestamp[ns][pyarrow]r5   r   )r/   r   r   r   )r   r   get_indexerrH   r   r  r;   r   )r   r=  r   targetr>   r?   result2s          r"   test_get_indexer_pyarrowz'TestGetIndexer.test_get_indexer_pyarrow  s     <333677"= 	)E!H$EfRj(F""6**8IIIRW555
#FH555 $$U++
#GX66666r$   c                     t          dd          }|                    |                    d                     }|                    |          }t          j        ||           d S )Nr   r   r   c                 *    |                                  S )N)r   )xs    r"   <lambda>z;TestGetIndexer.test_get_indexer_date_objs.<locals>.<lambda>(  s    16688 r$   )r   r?  mapr;   r   r,  s       r"   test_get_indexer_date_objsz)TestGetIndexer.test_get_indexer_date_objs%  s_    R000););!<!<==??3''
#FH55555r$   c           	         t          dd          }t          j        g dt          j                  }t	          j        |                    |          |           |d         t          j        g d          z   }t	          j        |                    |d          t          j        g d	t          j                             t	          j        |                    |d
          t          j        g dt          j                             t	          j        |                    |d          t          j        g dt          j                             t	          j        |                    |dt          j	        d                    t          j        g dt          j                             t          j	        d          t          j	        d          t          j	        d          
                                g}t	          j        |                    |dd |D                       t          j        g dt          j                             t          j	        d          
                                t          j	        d          
                                dg}d}t          j        t          |          5  |                    |d|           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    |dg         dd           d d d            d S # 1 swxY w Y   d S )Nr   r2   r   r   r   r   )z-1 hourz12 hoursz1 day 1 hourpadr   backfillnearest)r   r   r   z1 hour)	tolerance)r   r5   r   c                 6    g | ]}t          j        |          S rh   )rH   r   ).0rE  s     r"   
<listcomp>z3TestGetIndexer.test_get_indexer.<locals>.<listcomp>F  s"    -Q-Q-QAbnQ.?.?-Q-Q-Qr$   z2 hourr   z*Could not convert 'foo' to NumPy timedeltarS   zabbreviation w/o a number)methodrM  )r   rH   r   r  r;   r   r?  rq   to_timedeltar   to_timedelta64rU   rV   rW   )r   r*   rN   r@  tol_rawtol_badr   s          r"   test_get_indexerzTestGetIndexer.test_get_indexer,  s   q111hyyy000
#COOC$8$8#>>>Q"/*Q*Q*QRRR
#OOFE**BHZZZrw,O,O,O	
 	
 	
 	#OOFJ//)))271S1S1S	
 	
 	
 	#OOFI.."'0R0R0R	
 	
 	
 	#OOFIh9O9OOPPHZZZrw///	
 	
 	

 L""L""L""1133

 	#OO	-Q-Q-Q-Q-Q    HZZZrw///		
 	
 	
 L""1133L""1133

 ;]:S111 	B 	BOOFIOAAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B]:-HIII 	I 	IOOCHY%OHHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	Is$   ?K$$K(+K(
 L77L;>L;r@    r   
2020-01-02
2020-01-01r/   c                     t          t          d          t          d          g          }|                    |          }t          j        ddgt          j                  }t          j        ||           d S )NrY  rX  r   r   r   r   r   r?  rH   r   r  r;   r   )r   r@  r   r>   r?   s        r"   test_get_indexer_mixed_dtypesz,TestGetIndexer.test_get_indexer_mixed_dtypesU  sl     	, 7 7<9P9PQRR##F++8QF"'222
#FH55555r$   ztarget, positionsi'  r5   r   c                     t          t          d          t          d          g          }|                    |          }t          j        |t          j                  }t          j        ||           d S )NrY  rX  r   r[  )r   r@  	positionsr   r>   r?   s         r"   #test_get_indexer_out_of_bounds_datez2TestGetIndexer.test_get_indexer_out_of_bounds_datec  sh     	, 7 7<9P9PQRR##F++8IRW555
#FH55555r$   c                     t          ddd          }|g d         }d}t          j        t          |          5  |                    |d	           d d d            d S # 1 swxY w Y   d S )
Nr   z3/1/2000rA   rD   )r   r   r/   z0index must be monotonic increasing or decreasingrS   rJ  )rQ  )r   rU   rV   rW   r?  )r   rL   rng2r   s       r"   *test_get_indexer_pad_requires_monotonicityz9TestGetIndexer.test_get_indexer_pad_requires_monotonicityr  s    Zc::: 999~@]:S111 	0 	0S///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s   AA#&A#N)rc   rd   re   r   
skip_if_norU   rf   rg   rB  rH  rV  r   r   r\  r_  rb  rh   r$   r"   r;  r;    s       R]9[WtUm447 7 54 7$6 6 6'I 'I 'IR [T$1yy667Y|$$dd4A&6&67	
 6 6 6 [d4A		, 7 782q'Bi%%ttD!Q'7'781b'Bd4AT1a 0 01B8<	
 6 6 60 0 0 0 0r$   r;  c                       e Zd Zd Zd ZdS )TestMaybeCastSliceBoundc                     t          dddd          }|                    dd          }t          d          }||k    sJ |                    dd	          }t          d
          }||k    sJ d S )N1hr   r5  r   )r   rp   r\   r   z
2015-01-02r  z2015-01-02 23:59:59.999999999r  z2015-01-02 00:00:00)r   _maybe_cast_slice_boundr   )r   	empty_idxr  rN   r  s        r"   "test_maybe_cast_slice_bounds_emptyz:TestMaybeCastSliceBound.test_maybe_cast_slice_bounds_empty~  s|    D!dKKK	11,HH788||||00vFF-..s{{{{{{r$   c                     t          ddg          }|                    dd          }t          d          }||k    sJ d S )N2017z
2017-01-01r  )r   rh  r   r   s       r"   )test_maybe_cast_slice_duplicate_monotoniczATestMaybeCastSliceBound.test_maybe_cast_slice_duplicate_monotonic  sM    VV,--,,\6BB\**!!!!!!r$   N)rc   rd   re   rj  rm  rh   r$   r"   re  re  }  s2        
 
 
" " " " "r$   re  c                      e Zd Zej                            dddg          d             Zej                            deee	g          ej                            dddg          d	                         Z
ej                            dee	g          ej                            d
ddg          ej                            dddg          d                                     Zej                            dee	g          d             ZdS )TestGetSliceBoundsr=  TFc                 t   t          ddd          }t          j        d          }t          d          }||z
  }||z   }|ro|t          d                              d          z
  }|t          d                              d          z
  }|t          d                              d          z
  }|                    |d	
          }|dk    sJ |                    |d
          }|dk    sJ t          j        d|          }	|	j        ||         }
|	j        dd         }t          j
        |
|           d S )Nr   r   r   )r[   r   rp   r   z2000-01-01 01:00:00r   usr  sider  r/   r   )r   rq   r   r   r   get_slice_boundr  r   r  r;   r  )r   r=  r   r   r  r[   stopr  r  serr>   r?   s               r"   $test_get_slice_bound_mismatched_unitz7TestGetSliceBounds.test_get_slice_bound_mismatched_unit  s?    CCCC\!__,--RBw 	5IaLL00666EIaLL00666E)A,,..t444D$$U$88qyyyy%%d%99zzzz i'''t$8AaC=
vx00000r$   boxzside, expected)r  r4   )r  r,   c                    |}t          dd                              |          } |ddd          }|t          urd nt          }d}	t	          j        ||	          5  |Kt          j        t          d	          5  |	                    ||
           d d d            n# 1 swxY w Y   n|	                    ||
          }
|
|k    sJ d d d            d S # 1 swxY w Y   d S )N
2000-01-03
2000-02-11i  r   r   yearmonthdayz1Slicing with a datetime.date object is deprecatedrS   Cannot compare tz-naiverr  )
r   r   r   r
   r;   assert_produces_warningrU   rV   r   rt  )r   rx  rs  r?   r   r   r   r   warnr   r>   s              r"   %test_get_slice_bounds_datetime_withinz8TestGetSliceBounds.test_get_slice_bounds_datetime_within  s    L,77CCBGGct1!,,,$ttNA'C888 	* 	*~]94MNNN : :))#D)999: : : : : : : : : : : : : : : ..s.>>))))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s6   C<B C B$	$C'B$	(#CCCrs  r  r  zyear, expected)i  r   )rW  r   c                 H   |}t          dd                              |          } ||dd          }|Mt          j        t          d          5  |                    ||           d d d            d S # 1 swxY w Y   d S |                    ||          }	|	|k    sJ d S )	Nrz  r{  r   r   r|  r  rS   rr  )r   r   rU   rV   r   rt  )
r   rx  rs  r}  r?   r   r   r   r   r>   s
             r"   &test_get_slice_bounds_datetime_outsidez9TestGetSliceBounds.test_get_slice_bounds_datetime_outside  s    L,77CCBGGct1!,,,>y0IJJJ 6 6%%c%5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 **3T*::FX%%%%%%s   A66A:=A:c           	      t   |}t          ddg                              |          } |ddd          }|Wt          j        t          d          5  |                    | |ddd                     d d d            d S # 1 swxY w Y   d S |                    | |ddd                    }d}||k    sJ d S )	Nz
2010-01-01z
2010-01-03r   r   r  rS   r/   )r   r   )r   r   rU   rV   r   
slice_locs)r   rx  r   r   r   r   r>   r?   s           r"   test_slice_datetime_locsz+TestGetSliceBounds.test_slice_datetime_locs  s    |\:;;GGKKc$1oo>y0IJJJ 7 7  cc$1oo6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 %%c33tQ??;;FHX%%%%%%s   "B  BBN)rc   rd   re   rU   rf   rg   rw  r   r   r   r  r  r  rh   r$   r"   ro  ro    sJ       [WtUm441 1 5412 [UT8Y$?@@[-\/JKK* * LK A@*& [UXy$9::[Vfg%677[-	:/FGG& & HG 87 ;:&  [UXy$9::& & ;:& & &r$   ro  c                   `    e Zd Zd Zej                            dg d          d             ZdS )TestIndexerBetweenTimec           
         t          ddd          }d}t          j        t          |          5  |                    t          ddd	d          t          ddd	d
                     d d d            d S # 1 swxY w Y   d S )Nr   1/5/20005minrD   zGCannot convert arg \[datetime\.datetime\(2010, 1, 2, 1, 0\)\] to a timerS   r   r   r/   r,   )r   rU   rV   rW   indexer_between_timer   )r   rL   r   s      r"   test_indexer_between_timez0TestIndexerBetweenTime.test_indexer_between_time  s    Zf===X]:S111 	W 	W$$XdAq!%<%<htQPQST>U>UVVV	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	W 	Ws   7A44A8;A8r   )rq  r   r  c                    t          ddd          }|j        j        }|                    d| d          }t	          |j                                      ||j                  }t          |          }|j        |j        k    sJ t          dd	          }t          d
d          }|	                    ||          }	|	                    ||          }
t          j        |	|
           t          dd	dd          }t          d
ddd          }|	                    ||          }	|	                    ||          }
t          j        |	|
           d S )Nr   r  r  rD   zM8[]r   r      r/      r   in  i  )r   r   _ndarrayr   type_simple_newr:   r   r   r  r;   r   )r   r   rL   arr_nanor   r   r]   r  tocr>   r?   s              r"   "test_indexer_between_time_non_nanoz9TestIndexerBetweenTime.test_indexer_between_time_non_nano  sA   
 Zf===9%oomDmmm,,39oo))#SY)??C  yCI%%%%1bkk1bkk))#s33++C55
#FH555 1b!U##1b!T""))#s33++C55
#FH55555r$   N)rc   rd   re   r  rU   rf   rg   r  rh   r$   r"   r  r    s[        W W W [V%6%6%6776 6 876 6 6r$   r  )*r   r   r   r   numpyrH   rU   pandas._libsr   r  pandas.compat.numpyr	   pandas.errorsr
   pandas.util._test_decoratorsutil_test_decoratorsr   pandasrq   r   r   r   r   r   r   pandas._testing_testingr;   pandas.tseries.frequenciesr   rE   rF   r   rj   r   r   r/  r;  re  ro  r  rh   r$   r"   <module>r     s                   * * * * * * ' ' ' ' ' ' ( ( ( ( ( ( ) ) ) ) ) ) ) ) )                          0 0 0 0 0 0XdAq!!88D!Q#7#7
sV! V! V! V! V! V! V! V!rg0 g0 g0 g0 g0 g0 g0 g0Tl( l( l( l( l( l( l( l(^e" e" e" e" e" e" e" e"P       ,j0 j0 j0 j0 j0 j0 j0 j0Z" " " " " " " "*Q& Q& Q& Q& Q& Q& Q& Q&h#6 #6 #6 #6 #6 #6 #6 #6 #6 #6r$   