
    Pi?                        d dl mZ d dlmZmZmZ d dlmZ d dlmZ d dl	Z	d dl
Z
d dlZ
d dlmZ d dlZd dlZd dlmZ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  G d
 d          Z  G d d          Z!dS )    )annotations)datetime	timedeltatimezone)partial
attrgetterN)gettz)astype_overflowsafe	timezones)DatetimeIndexIndex	Timestamp
date_rangeoffsetsto_datetime)period_arrayc            
         e Zd Zd Zd Zd Zej                            d e	dddd	           e
j        d
d          g          d             Zd Zd Zd Zd Zd Zej                            dddiddidddg          d             Zej                            dddiddidddg          d             Zd Zd Zd Zd Zd Zej                            ddg ed d!d!          gg          d"             Zd# Zd$ Zd% Zej                            d&d'd(g          d)             Zd* Zd+ Z ej                            de!e"j#        e"j$        g          d,             Z%d- Z&d. Z'ej                            dd/d0 e(j)        d0           e*d1d02          j+        g          d3             Z,ej                            dg d4          d5             Z-d6 Z.ej                            d7e/e0g          ej                            d8e"j1         e2e"j1        e!9          e3g          ej                            d:d;d<g          d=                                     Z4d> Z5d? Z6d@ Z7dA Z8dB Z9dC Z:dD Z;dE Z<dF Z=ej                            d e(j)        dG           e>dG          g          dH             Z?ej                            dIdGdJg          dK             Z@dL ZAej                            dMdNdOg          dP             ZBej                            dIdGdJg          dQ             ZCej                            ddR e>dG          g          ej                            dSdTdUg          ej                            dVe*e0g          dW                                     ZDej                            dg dX          dY             ZEdZ ZFd[ ZGej                            dd\d]g          d^             ZHd/S )_TestDatetimeIndexc                    t          j        dd          }t          |gd          }t          |                    d          gd          }t	          j        ||           d S )N   D
US/PacifictzM8[s])np
datetime64r   astypetmassert_index_equal)selfvalresultexpecteds       /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/indexes/datetimes/test_constructors.pytest_from_dt64_unsupported_unitz1TestDatetimeIndex.test_from_dt64_unsupported_unit%   sa    mAs##u666 #**W"5"5!6<HHH
fh/////    c                   t          dddd          }d}t          j        t          |          5  t	          |d            d d d            n# 1 swxY w Y   t          j        t          |          5  t	          t          j        |          d            d d d            n# 1 swxY w Y   d	}t          j        t          |          5  t	          g d
d            d d d            d S # 1 swxY w Y   d S )N
2016-01-01
   UTCnsperiodsr   unitz:Passed data is timezone-aware, incompatible with 'tz=None'matchr   z3Cannot pass both a timezone-aware dtype and tz=NoneM8[ns, UTC]dtyper   )r   pytestraises
ValueErrorr   r   arrayr"   dtimsgs      r&   test_explicit_tz_nonez'TestDatetimeIndex.test_explicit_tz_none-   s   re$GGGJ]:S111 	( 	(#$''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( ]:S111 	2 	2"(3--D1111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 D]:S111 	< 	<"Md;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s5   AAA5$B%%B),B)C--C14C1c                   d}t          j        t          |          5  t          t          j        t          d          gd           d d d            n# 1 swxY w Y   t          j        t          |          5  t          t          j        t          d          j        gd           d d d            d S # 1 swxY w Y   d S )NQInferred frequency None from passed values does not conform to passed frequency Dr1   
2011-01-01r   freq)r6   r7   r8   r   pdNaTr   _valuer"   r<   s     r&   test_freq_validation_with_natz/TestDatetimeIndex.test_freq_validation_with_nat<   s]   $ 	 ]:S111 	G 	G269\#:#:;#FFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G]:S111 	N 	N269\#:#:#ABMMMM	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	Ns#   +AAA;0B88B<?B<indexr*      r   r-   r.   z1 Day)r/   c                v    |j         }|g d         }|j        J |                    |          }|j        J d S )N)r            r   )_datarB   _shallow_copy)r"   rH   r9   arrr$   s        r&   %test_shallow_copy_inherits_array_freqz7TestDatetimeIndex.test_shallow_copy_inherits_array_freqI   sN     OOO$x$$S)){"""""r(   c                ,   t          t          j        dddgd          }||j        fD ]j}t          j        |          }t          j        |          }t          j        |          }|||fD ]&}t          |          }t          j        ||           'kd S )Nz
2015-01-01z1999-04-06 15:14:13
US/Easternr   )	r   rC   rD   rN   CategoricalIndexCategoricalSeriesr    r!   )r"   r;   dtobjcicarrcserobjr$   s           r&   test_categorical_preserves_tzz/TestDatetimeIndex.test_categorical_preserves_tz[   s    V\#8,GL
 
 
 39% 		3 		3E $U++B>%((D9R==DD$' 3 3&s++%fc22223		3 		3r(   c                |   t          j        ddgd          }t          j        t          d          5  t          |           d d d            n# 1 swxY w Y   t          j        t          d          5  t          |           d d d            n# 1 swxY w Y   t          j        t          d          5  t          t          |                     d d d            n# 1 swxY w Y   t          j        t          d          5  t          t          |                     d d d            d S # 1 swxY w Y   d S )N2016Q12016Q2QrA   zPeriodDtype data is invalidr1   )rC   PeriodIndexr6   r7   	TypeErrorr   r   r   r"   datas     r&    test_dti_with_period_data_raisesz2TestDatetimeIndex.test_dti_with_period_data_raisesl   s$   ~x2===]9,IJJJ 	  	 $	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ]9,IJJJ 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]9,IJJJ 	. 	.,t,,---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. ]9,IJJJ 	, 	,T**+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,sG   AAA6BBB8C!!C%(C%D11D58D5c                   t          j        dgd          }d}t          j        t          |          5  t          |           d d d            n# 1 swxY w Y   t          j        t          |          5  t          |           d d d            n# 1 swxY w Y   t          j        t          |          5  t          t          j        |                     d d d            n# 1 swxY w Y   t          j        t          |          5  t          t          j        |                     d d d            d S # 1 swxY w Y   d S )Nr   zm8[ns]r5   z3timedelta64\[ns\] cannot be converted to datetime64r1   )	r   r9   r6   r7   rb   r   r   rC   TimedeltaIndex)r"   rd   r<   s      r&   %test_dti_with_timedelta64_data_raisesz7TestDatetimeIndex.test_dti_with_timedelta64_data_raises|   s(   x8,,,D]9C000 	  	 $	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  ]9C000 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]9C000 	3 	3"+D11222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 ]9C000 	1 	1)$//000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1sG   AAA7BBB9"C''C+.C+"D<<E E c                    t          d          t          d          g}t          j                            |          }t	          |          }t          |          t          u sJ |j        |j        k    sJ d S )Nz2012-05-01T01:00:00.000000z2016-05-01T01:00:00.000000)r   rC   arraysSparseArrayr   typer5   )r"   valuesrP   r$   s       r&   "test_constructor_from_sparse_arrayz4TestDatetimeIndex.test_constructor_from_sparse_array   sw     233233
 i##F++sF||u$$$$|sy((((((r(   c                F   t          j        t          ddd          t          ddt          j        d          d          t          d          t           j        t          d          gt          dddd          d	          }|j        j        j	        j
        dk    sJ d S )
N20130101rK   r-   )r/   r0   rS   r.   20130103)r/   rB   r0   )dtdttzdt_with_nulldtns)rC   	DataFramer   zoneinfoZoneInfor   rD   rt   r5   r   key)r"   dfs     r&   test_construction_cachingz+TestDatetimeIndex.test_construction_caching   s    \ QTBBB"h.?.M.MTX   j))Fj))!
 #:qt$OOO 
 
 w}#|333333r(   kwargsr   zdtype.tzr5   r4   c                    |}t          ddd|d          fd|                                D             }t          fi |}t          j        |           d S )Nrq   rI   hr-   r/   rB   r   r0   c                H    i | ]\  }}| t          |                    S  r   .0rz   r#   is      r&   
<dictcomp>z@TestDatetimeIndex.test_construction_with_alt.<locals>.<dictcomp>   /    IIIhc3#z#q))IIIr(   )r   itemsr   r    r!   )r"   r}   tz_aware_fixturer   r$   r   s        @r&   test_construction_with_altz,TestDatetimeIndex.test_construction_with_alt   sq    
 z132DIIIIIII&,,..IIIq++F++
a(((((r(   c                   |}t          ddd|d                              d           fd|                                D             }d|v rQt          j        d	                              |d                   }t          fi |}t          j        ||           t                              d           j        d	          }                    d                               d          }t          j        ||           d
}t          j
        t          |          5  t                              d           j        j        t          j        d                     d d d            d S # 1 swxY w Y   d S )Nrq   rI   r   r-   r   c                H    i | ]\  }}| t          |                    S r   r   r   s      r&   r   zLTestDatetimeIndex.test_construction_with_alt_tz_localize.<locals>.<dictcomp>   r   r(   r   r,   r   -cannot supply both a tz and a dtype with a tzr1   z	US/Hawaiir4   )r   
_with_freqr   r   asi8
tz_convertr    r!   tz_localizer6   r7   r8   r5   rx   ry   )	r"   r}   r   r   r$   r%   i2r<   r   s	           @r&   &test_construction_with_alt_tz_localizez8TestDatetimeIndex.test_construction_with_alt_tz_localize   s   
 z132DIIILLIIII&,,..III6>>"16e444??tMMF$Q11&11H!&(333 1==..3>>>==&&22599
b(+++ >]:S111 	 	d##(g$[11   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   %AE44E8;E8c                   t          t          d          t          d          gd          }t          t          d          t          d          gd          }t          j        ||d           t          |t                    sJ |j        J t          t          dd	          t          d
d	          gd          }t          t          d          t          d
          gdd          }t          j        ||d           t          |t                    sJ |j        J |j        |j        k    sJ t          t          dd	          t          dd	          gd          }t          t          d          t          d          gdd          }t          j        ||d           t          |t                    sJ |j        J |j        |j        k    sJ t          t          d          t          d
d	          gd          }t          t          d          t          d
d	          gdd          }t          j        ||d           t          |t                    rJ t          t          dd	          t          d
d	          gd          }t          t          dd	          t          d
d	          gdd          }t          j        ||d           t          |t                    rJ d}t          j        t          |          5  t          ddg           d d d            n# 1 swxY w Y   t          t          d          gd          }t          t          d          gd          }t          j        ||d           t          |t                    sJ |j        J t          t          dd	          gd          }t          t          d          gdd          }t          j        ||d           t          |t                    sJ |j        J |j        |j        k    sJ d S )Nr@   
2011-01-02idxnameTexact2011-01-01 10:00
Asia/Tokyor   2011-01-02 10:00r   r   rS   2011-08-01 10:00objectr5   r   z6Mixed timezones detected. Pass utc=True in to_datetimer1   z2013-11-02 22:00-05:00z2013-11-03 22:00-06:00)
r   r   r   r    r!   
isinstancer   r6   r7   r8   )r"   r$   expr<   s       r&   ,test_construction_index_with_mixed_timezonesz>TestDatetimeIndex.test_construction_index_with_mixed_timezones   s@   	,//<1H1HIPUVVV|$$i&=&=>U
 
 
 	fc6666&-00000y    ,>>>,>>> 
 
 
 )**I6H,I,IJ
 
 

 	fc6666&-00000y$$$yCF"""" ,>>>,>>> 
 
 
 )**I6H,I,IJ
 
 

 	fc6666&-00000y$$$yCF"""" ,--,>>> 
 
 
 ,--,>>> 
 
 
 	fc6666fm44444,>>>,>>> 
 
 
 ,>>>,>>> 
 
 
 	fc6666fm44444F]:S111 	P 	P35MNOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	,//0u===Y|445EBBB
fc6666&-00000y    	"4FFFGeTTT)**+5
 
 
 	fc6666&-00000y$$$yCF""""""s   L;;L?L?c           	        t          t          j        t          d          t          j        t          d          gd          }t	          t          j        t          d          t          j        t          d          gd          }t          j        ||d           t          |t                    sJ |j        J t          t          j        t          dd	          t          j        t          d
d	          gd          }t	          t          j        t          d          t          j        t          d
          gdd          }t          j        ||d           t          |t                    sJ |j        J |j        |j        k    sJ t          t          dd	          t          j        t          dd	          gd          }t	          t          d          t          j        t          d          gdd          }t          j        ||d           t          |t                    sJ |j        J |j        |j        k    sJ t          t          j        t          d          t          j        t          d
d	          gd          }t          t          j        t          d          t          j        t          d
d	          gdd          }t          j        ||d           t          |t                    rJ t          t          j        t          dd	          t          j        t          d
d	          gd          }t          t          j        t          dd	          t          j        t          d
d	          gdd          }t          j        ||d           t          |t                    rJ t          t          j        t          j        gd          }t	          t          j        t          j        gd          }t          j        ||d           t          |t                    sJ |j        J d S )Nr@   r   r   r   Tr   r   r   r   r   r   rS   r   r   r   )	r   rC   rD   r   r   r    r!   r   r   )r"   r$   r   s      r&   5test_construction_index_with_mixed_timezones_with_NaTzGTestDatetimeIndex.test_construction_index_with_mixed_timezones_with_NaT9  sl   VY|,,bfi6M6MN
 
 
 VY|,,bfi6M6MN
 
 
 	fc6666&-00000y    ,>>>,>>>	 
 
 
 ,--,--	 	
 	
 	
 	fc6666&-00000y$$$yCF"""" ,>>>,>>>
 
 
 
 )**BFI>P4Q4QR
 
 

 	fc6666&-00000y$$$yCF"""" ,--,>>>	 
 
 
 ,--,>>>	 	
 	
 	
 	fc6666fm44444,>>>,>>>	 
 
 
 ,>>>,>>>	 	
 	
 	
 	fc6666fm44444 'e444RVRV,5999
fc6666&-00000y     r(   c                   t          t          d          t          d          gd          }t          t          d          t          d          gd          }t          j        ||d           t	          |t                     sJ t          t          dd	          t          d
d	          gd          }t          t          d          t          d
          gdd          }t          j        ||d           t	          |t                     sJ t          t          dd	          t          dd	          gd          }t          t          d          t          d          gdd          }t          j        ||d           t	          |t                     sJ d}t          j        t          |          5  t          t          dd	          t          d
d	          gd           d d d            n# 1 swxY w Y   t          t          d          t          d
d	          gdd          }t          t          dd	          t          d
d	                              d          gdd          }t          j        ||           t          t          dd	          t          d
d	          gdd          }t          t          dd	                              d          t          d
d	          gdd          }t          j        ||           t          t          dd	          t          d
d	          gdd          }t          j        ||           d S )Nr@   r   r   r   Tr   r   r   r   r   r   rS   r   z!cannot be converted to datetime64r1   zM8[us, US/Eastern]r   )	r   r   r    r!   r   r6   r7   r8   r   )r"   r$   r   r<   r;   r%   s         r&   *test_construction_dti_with_mixed_timezonesz<TestDatetimeIndex.test_construction_dti_with_mixed_timezones  sK    |$$i&=&=>U
 
 
 |$$i&=&=>U
 
 
 	fc6666&-00000 ,>>>,>>> 
 
 
 )**I6H,I,IJ
 
 

 	fc6666&-00000 ,>>>,>>> 
 
 
 )**I6H,I,IJ
 
 

 	fc6666&-00000 2]:S111 	 	0\BBB0\BBB    	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ,--,>>> 
 
 
 !,>>>,>>>II,WW 
 
 
 	c8,,, ,>>>,>>> 
 
 
 !,>>>II,WW,>>> 
 
 
 	c8,,, ,>>>,>>> '
 
 
 	c8,,,,,s    2G>>HHc                   t          d          t          j        t          d          g}t          j        t          |          t          |                     t          j        t          t          j        |                    t          t          j        |                               t          j	        t          j        t          d          g}t          j        t          |          t          |                     t          j        t          t          j        |                    t          t          j        |                               d S )Nr@   z
2011-01-03)
r   rC   rD   r    r!   r   r   r   r9   nan)r"   rP   s     r&   "test_construction_base_constructorz4TestDatetimeIndex.test_construction_base_constructor  s    &&	,0G0GH
eCjj-*<*<===
eBHSMM22M"(3--4P4PQQQvrvy667
eCjj-*<*<===
eBHSMM22M"(3--4P4PQQQQQr(   c                   t          ddd          t          ddd          t          ddd          t          ddd          g}t          |d          }t          |          }t          j        ||           t	          |           d S )Ni  r   i  i  ip  M8[us]rg   )r   r   r    r!   r   )r"   datesr   ress       r&   test_construction_outofboundsz/TestDatetimeIndex.test_construction_outofbounds  s     T1a  T1a  T1a  T1a  	
 E***Ell
c3'''er(   rd   z
1400-01-01ix  r   c                $    t          |           d S )N)r   rc   s     r&   test_dti_date_out_of_rangez,TestDatetimeIndex.test_dti_date_out_of_range+  s     	dr(   c                N   t          ddd          t          ddd          t          ddd          g}t          |t          j                              j        }t          |t          j                              }t          g ddd	
          }t          j        ||           d S )Ni  r+         	   rA   )z
2013-10-07z
2013-10-08z
2013-10-09r   Br5   rB   )r   r   r   BDayrn   r    r!   )r"   r   rd   r$   r%   s        r&   test_construction_with_ndarrayz0TestDatetimeIndex.test_construction_with_ndarray0  s    $A&&r1(=(=xbRS?T?TUU888?t',..999 666hS
 
 
 	fh/////r(   c                   t          j        dd          }t          j        |                    d          g          }t	          |                              d          }t	          dgd          }t          j        ||           t          j        d           5  t	          |d	          }d d d            n# 1 swxY w Y   t	          dgd
          }t          j        ||           d S )Nz2000-01-01 00:00:00r-   i8
US/Centralz2000-01-01T00:00:00zM8[ns, US/Central]rg   r,   r   r3   )	r   r   r9   viewr   r   r    r!   assert_produces_warning)r"   r#   rn   r$   r%   s        r&   -test_integer_values_and_tz_interpreted_as_utcz?TestDatetimeIndex.test_integer_values_and_tz_interpreted_as_utc:  s   m1488388D>>*++v&&22<@@ "7!8@TUUU
fh/// '-- 	5 	5"6e444F	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 "7!8NNN
fh/////s   B99B= B=c                   d}t          j        t          |          5  t          d           d d d            n# 1 swxY w Y   d t	          d          D             }t          |          }t          d t	          d          D                       }t          j        ||           t          j        g d          }t          |          }t          |	                    d                    }t          j        ||           t          |
                    d	          j                  
                    d
          }t          j        ||           t          j        g d          }t          |          }t          |	                    d                    }t          j        ||           t          |
                    d	          j                  
                    d
          }t          j        ||           d}t          j        t          |          5  t          g dd           d d d            d S # 1 swxY w Y   d S )Nz8DatetimeIndex\(\.\.\.\) must be called with a collectionr1   1/1/2000c              3  X   K   | ]%}t          d dd          t          |          z   V  &dS )  r   Nr   r   r   r   s     r&   	<genexpr>z>TestDatetimeIndex.test_constructor_coverage.<locals>.<genexpr>P  s9      FFqxa##ill2FFFFFFr(   r+   c                P    g | ]#}t          d dd          t          |          z   $S )r   r   r   r   s     r&   
<listcomp>z?TestDatetimeIndex.test_constructor_coverage.<locals>.<listcomp>S  s/    DDDQXdAq!!IaLL0DDDr(   )
2000-01-01
2000-01-02z
2000-01-03Or-   us)r   r   rD   r?   )r   r   z
2000-01-04r   rA   )r6   r7   rb   r   ranger    r!   r   r9   r   as_unitr   r8   )r"   r<   genr$   r%   strings	from_intss          r&   test_constructor_coveragez+TestDatetimeIndex.test_constructor_coverageJ  s   I]9C000 	& 	&*%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& GFE"IIFFFs## DD%))DDD
 
 	fh/// (EEEFFw'' !4!455
fh///!("2"24"8"8"=>>FFtLL	
i222 (>>>??w'' !4!455
fh///!("2"24"8"8"=>>FFtLL	
i222$ 	 ]:S111 	P 	PDDD3OOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps   :>>H<<I I rB   YSzW-SUNc           
     >   t          dd|          }t          dd|t          t          d                              }t          j        ||           t          dd|d	          }t          j        |j        |j                   t          d
d|          }t          dd|t          t          d                              }t          j        ||           t          dd|d          }t          j        |j        |j                   t          dd|          }t          dd|t          t          d                              }t          j        ||           t          dd|d	          }t          j        |j        |j                   t          dd|          }t          dd|t          t          d                              }t          j        ||           t          dd|d          }t          j        |j        |j                   d S )Nz2013-01-01T00:00:00-05:00z2016-01-01T23:59:59-05:00rA   z2013-01-01T00:00:00z2016-01-01T23:59:59i)minutesrB   r   zAmerica/Limaz2013-01-01T00:00:00+09:00z2016-01-01T23:59:59+09:00i  r   z2013/1/1 0:00:00-5:00z2016/1/1 23:59:59-5:00z2013/1/1 0:00:00+9:00z2016/1/1 23:59:59+09:00)r   r   r   r    r!   assert_numpy_array_equalr   )r"   rB   r   r%   expected_i8s        r&   $test_constructor_datetime64_tzformatz6TestDatetimeIndex.test_constructor_datetime64_tzformatq  sv    ')D4
 
 
 !!	$///00	
 
 
 	c8,,, !#8t
 
 
 	#CHk.>???')D4
 
 
 !!	#...//	
 
 
 	c8,,, !#8t
 
 
 	#CHk.>??? 02JQUVVV!!	$///00	
 
 
 	c8,,, !#8t
 
 
 	#CHk.>???02KRVWWW!!	#...//	
 
 
 	c8,,, !#8t
 
 
 	#CHk.>?????r(   c                :   t          ddgd          }t          ddg                              d                              d          }t          j        ||           t          ddgd                              d          }t          j        ||           d S )N
2013-01-01
2013-01-02datetime64[ns, US/Eastern]rg   r-   rS   r   )r   r   r   r    r!   )r"   r   r%   s      r&   test_constructor_dtypez(TestDatetimeIndex.test_constructor_dtype  s    <(0L
 
 
 <677WT]][&& 	
 	c8,,,\<8\JJJRRSWXX
c8,,,,,r(   c                   t          ddgd          }d}t          j        t          |          5  t          |d           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   d
}t          j        t          |          5  t          |dd           d d d            n# 1 swxY w Y   t          |d          }t          j        ||           d S )Nr   r   r   rg   zNcannot supply both a tz and a timezone-naive dtype \(i\.e\. datetime64\[ns\]\)r1   datetime64[ns]zDdata is already tz-aware US/Eastern, unable to set specified tz: CETzdatetime64[ns, CET]r   CET)r   r5   )r   r6   r7   r8   rb   r    r!   )r"   r   r<   r$   s       r&   )test_constructor_dtype_tz_mismatch_raisesz;TestDatetimeIndex.test_constructor_dtype_tz_mismatch_raises  s   <(0L
 
 

+ 	 ]:S111 	7 	7#%56666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 U]9C000 	< 	<#%:;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<=]:S111 	M 	M#%/KLLLL	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M s*FGGG
c6*****s5   AAA7BBB=CC #C c                    d}t          j        t          |          5  t          ddg|           d d d            d S # 1 swxY w Y   d S )NzUnexpected value for 'dtype'r1   r   rL   rg   )r6   r7   r8   r   )r"   r5   r<   s      r&   %test_constructor_invalid_dtype_raisesz7TestDatetimeIndex.test_constructor_invalid_dtype_raises  s     -]:S111 	/ 	/1a&....	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   ?AAc                t    t          d          }t          |g          }|j        d         |j        k    sJ d S )Nl   )b0Z4 r   )r   r   
nanosecond)r"   t1r   s      r&   test_000constructor_resolutionz0TestDatetimeIndex.test_000constructor_resolution  s?    EFFRD!!~a BM111111r(   c                    t          dgd          }d}t          j        t          |          5  t	          j        d          |_        d d d            d S # 1 swxY w Y   d S )N2010r,   r   zCannot directly set timezoner1   r   )r   r6   r7   AttributeErrorrx   ry   r   r:   s      r&   test_disallow_setting_tzz*TestDatetimeIndex.test_disallow_setting_tz  s    VH///,]>555 	5 	5&|44CF	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   AAANAmerica/Los_Angeles2000r   c                    t          dd          }t          dd          }t          d|||d          }t          ddgdd	          }t          j        ||           t          j        d          |j        u sJ d S )
Nz2013-01-01 06:00:00r   r   z2013-01-02 06:00:00r   r-   )rB   startendr   r0   zM8[ns, America/Los_Angeles]r   )r   r   r   r    r!   rx   ry   r   )r"   r   r   r   r$   r%   s         r&   "test_constructor_start_end_with_tzz4TestDatetimeIndex.test_constructor_start_end_with_tz  s     /4IJJJ-2GHHHEsrMMM "$9:/
 
 

 	fh/// !67769DDDDDDr(   )r   rS   r   c                    t          j        d          }|                    |          }t          d|          j        }t          dg|          }|                    |          |j        u sJ d S )Npytzr   r   )r6   importorskipr   r   r   r   )r"   r   r   tz_innon_norm_tzr$   s         r&   )test_constructor_with_non_normalized_pytzz;TestDatetimeIndex.test_constructor_with_non_normalized_pytz  ss     "6**b!!51114xK888}}R  FI------r(   c                `   t          dd          t          dd          g}t          |                              d          }t          |d                                         |d                                         g                              d          }t	          j        ||           d S )Nz2016-10-30 03:00:00+0300zEurope/Helsinkir   z2016-10-30 03:00:00+0200r-   r   r   )r   r   r   to_pydatetimer    r!   )r"   tsr$   r%   s       r&   #test_constructor_timestamp_near_dstz5TestDatetimeIndex.test_constructor_timestamp_near_dst  s     05FGGG05FGGG
 r""**400 U  ""BqE$7$7$9$9:
 

'$-- 	 	fh/////r(   klassboxrg   z	tz, dtype)r   zdatetime64[ns, US/Pacific])Nr   c                    t          d|                              d          } | ||j        g          |          } ||g          }||k    sJ d S )Nz
2018-01-01r   r-   rg   )r   r   rE   )r"   r   r   r   r5   r   r$   r%   s           r&   test_constructor_with_int_tzz.TestDatetimeIndex.test_constructor_with_int_tz  sl     |+++33D99ssBI;''u5555";;!!!!!!r(   c                X    |}d}t          |g|          j        d         }||k    sJ d S )Nl     _S r   r   )r   r   )r"   tz_naive_fixturer   r$   r%   s        r&   test_construction_int_rountripz0TestDatetimeIndex.test_construction_int_rountrip$  s?    $ &b1116q9!!!!!!r(   c                   t          t          ddd          t          ddd          ddd          }t          d	 |D                       }t          g d
d                              d          }t	          j        ||           d S )Nr           zYE-DECzAustralia/Melbourner-   )rB   r   r0   c                <    g | ]}|                     d d          S )   r   )monthday)replacer   xs     r&   r   zYTestDatetimeIndex.test_construction_from_replaced_timestamps_with_dst.<locals>.<listcomp>5  s(    IIIa		q	 9 9IIIr(   )z2000-06-01 00:00:00z2001-06-01 00:00:00z2002-06-01 00:00:00z2003-06-01 00:00:00z2004-06-01 00:00:00z2005-06-01 00:00:00r   )r   r   r   r   r    r!   )r"   rH   r$   r%   s       r&   3test_construction_from_replaced_timestamps_with_dstzETestDatetimeIndex.test_construction_from_replaced_timestamps_with_dst,  s    dB##dB##$
 
 
 II5IIIJJ    %

 

 

 '$-- 	 	fh/////r(   c                    t          ddd          }d}t          j        t          |          5  t	          |d           d d d            d S # 1 swxY w Y   d S )	Nr*   rK   r   )r/   r   z?data is already tz-aware US/Central, unable to set specified tzr1   r   r   )r   r6   r7   rb   r   r:   s      r&   *test_construction_with_tz_and_tz_aware_dtiz<TestDatetimeIndex.test_construction_with_tz_and_tz_aware_dtiC  s    q\BBBO]9C000 	0 	0#,////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s   AAAc                2   t           j                                        }t          ddg|                              d          }t          t          d|          t          j        g                              d          }t          j	        ||           d S )N2018rD   r   r-   )
dateutilr   tzlocalr   r   r   rC   rD   r    r!   )r"   r   r$   r%   s       r&   &test_construction_with_nat_and_tzlocalz8TestDatetimeIndex.test_construction_with_nat_and_tzlocalJ  s    [  ""2666>>tDD )Fr":":":BF!CDDLLTRR
fh/////r(   c                x   t          ddgddd          }d}t          dd	d
d
                              |d          }t          |ddd          }t	          j        ||           d}t          dd	dd
                              |d          }t          |ddd          }t	          j        ||           d S )Nz2020-11-01 01:00:00z2020-11-02 01:00:00z datetime64[ns, America/New_York]r   F)r5   rB   	ambiguouszAmerica/New_Yorki     r   )yearr  r  hour)r  rL   r-   )r   r/   r  r0   )r   r/   r  r0   )r   r   r   r   r    r!   )r"   r%   r   r   r$   r   s         r&   +test_constructor_with_ambiguous_keyword_argz=TestDatetimeIndex.test_constructor_with_ambiguous_keyword_argP  s     !"$9:4	
 
 
 &t211===II J 
 
 %e$OOO
fh/// &T;;;GG H 
 
 Q%dKKK
fh/////r(   c                   |}t          d                              |d          }t          |ddd          }t          t          d|	          t          d
|	          g                              d          }t          j        ||           |}t          |ddd          }t          t          d|	          t          d|	          g                              d          }t          j        ||           d S )Nz2015-03-29 02:30:00shift_forward)nonexistentrL   r   r-   )r   r/   rB   r0   z2015-03-29 03:00:00+02:00r   z2015-03-29 04:00:00+02:00)r   r/   rB   r0   z2015-03-29 01:00:00+01:00)r   r   r   r   r   r    r!   )r"   warsawr   r   r$   r%   r   s          r&   -test_constructor_with_nonexistent_keyword_argz?TestDatetimeIndex.test_constructor_with_nonexistent_keyword_argj  s"    /00<</ = 
 
 %4HHH 5(CCC5(CCC
 

 '$-- 	 	fh/// QStDDD 5(CCC5(CCC
 

 '$-- 	 	fh/////r(   c                $   d}t          j        t          |          5  t          dgd           d d d            n# 1 swxY w Y   d}t          j        t          |          5  t	          dgd           d d d            d S # 1 swxY w Y   d S )Nz with no precision is not allowedr1   r   r   rg   z2The 'datetime64' dtype has no unit. Please pass in)r6   r7   r8   r   r   rF   s     r&   $test_constructor_no_precision_raisesz6TestDatetimeIndex.test_constructor_no_precision_raises  s    1]:S111 	8 	86(,7777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 C]:S111 	0 	06(,////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s!   =AA%BB	B	c                ~    t          dgd          }|j        dk    sJ |d         t          ddd          k    sJ d S )Nr   zdatetime64[us]rg   r   r   r   r   )r   r5   r   )r"   r;   s     r&   'test_constructor_wrong_precision_raisesz9TestDatetimeIndex.test_constructor_wrong_precision_raises  sQ    VH,<===yH$$$$1v4A........r(   c                
   t          t          j        t          dd          t          j        gt
                              }t          t          dd          t          j        g          }t          j
        ||           d S )N2019r,   r   rg   )r   r   r9   r   r   r   r   rC   rD   r    r!   )r"   r$   r%   s      r&   Htest_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nanzZTestDatetimeIndex.test_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nan  sl    rx6e!<!<!<bf EVTTTUU )Fu"="="=rv!FGG
fh/////r(   rS   c                    t          ddd|          g}t          |          }t          j        |j        |          sJ d S )N  r      )tzinfo)r   r   r   
tz_comparer   )r"   r   drH   s       r&   test_dti_from_tzaware_datetimez0TestDatetimeIndex.test_dti_from_tzaware_datetime  sK     dAr"---.a  #EHb1111111r(   tzstrzdateutil/US/Easternc                   ddg}t          |                              |          }t          ddd|d          }|                    d          }t	          ||	          }t	          t          j        |          |	          }t          j        ||           t          j        ||           t          j        ||           dS )
z^Test different DatetimeIndex constructions with timezone
        Follow-up of GH#4229
        z11/10/2005 08:00:00z11/10/2005 09:00:00z2005-11-10 08:00:00r   rL   r   )r   rB   r/   r   r0   Nr   )	r   r   r   r   r   r   r9   r    r!   )r"   r1  rP   idx1idx2idx3idx4s          r&   test_dti_tz_constructorsz*TestDatetimeIndex.test_dti_tz_constructors  s    
 %&;<3++E22'c1T
 
 
 t$$SU+++RXc]]u555
dD)))
dD)))
dD)))))r(   c                z    t          dddd|          }t          |d          }t          j        ||           d S )Nz03/12/2012 00:00r+   zW-FRIrS   r   )rd   r   r   r   r    r!   )r"   r0   rngrng2s       r&    test_dti_construction_idempotentz2TestDatetimeIndex.test_dti_construction_idempotent  sO    \PT
 
 
 #,777
c4(((((r(   prefix z	dateutil/c                l    t          t          ddd          g|dz             }|j         |d          d S )Nr+  r   ESTr   r   )r   r   r  )r"   r=  rH   s      r&   "test_dti_constructor_static_tzinfoz4TestDatetimeIndex.test_dti_constructor_static_tzinfo  s=     xa334%HHH

ar(   c                    t          dd|d          }t          t          |          dd          }t          j        ||           d S )Nz
2012-06-02r+   foo)r/   r   r   r   )r   rB   )r   r   listr    r!   )r"   r1  drdr2s       r&   test_dti_convert_datetime_listz0TestDatetimeIndex.test_dti_convert_datetime_list  sK    bUGGGDHH5s;;;
b#&&&&&r(   zpytz/US/Easternuse_strTFbox_clsc                f   t          |t                    rQ|                    d          r<t          j        d          }|                    |                    d                    }d}|}|s!t          |                                          }|t          ur|g}|sTt          |t          j
        j                  r5t          j                            d          }|                    |           t          j        t           |          5   |||           d d d            d S # 1 swxY w Y   d S )Nzpytz/r   z2013-11-03 01:59:59.999999zWe implicitly get fold=0.)reasonr1   r   )r   str
startswithr6   r   r   removeprefixr   r   r  r   tzfilemarkxfailapplymarkerr7   r8   )	r"   r   rH  rI  requestr   dtstritemrP  s	            r&   $test_dti_ambiguous_matches_timestampz6TestDatetimeIndex.test_dti_ambiguous_matches_timestamp  sn    b# 	92==#9#9 	9&v..Drw7788B, 	4U##1133D)##6D 	&:b(+*<== 	&
 ;$$,G$HHD%%%]:U333 	! 	!GDR    	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   D&&D*-D*)Nr,   r   c                ~   t          d          }d}|d| d}|ddg}t          ||          }|d                             |          t          |d	         |
          t          |d         dd                              |          g}d |D             }t          j        |d          }t          |d          }	|(|	                    d                              |          }	t          j        ||	           t          t          j        |t                    |          }
t          j        |
|	           d S )Nz
2999-01-01r   zM8[us, ]z2999-01-02 03:04:05.678910i	  rg   r   r   r   rL   r   T)r0   utcc                B    g | ]}|                     d           j        S )r   )r   asm8r  s     r&   r   zNTestDatetimeIndex.test_dti_constructor_with_non_nano_dtype.<locals>.<listcomp>   s%    <<<QAIIdOO(<<<r(   r,   )
r   r   r   r   r   r   r9   r    r!   r   )r"   r   r   r5   valsr$   	pointwiseexp_valsexp_arrr%   result2s              r&   (test_dti_constructor_with_non_nano_dtypez:TestDatetimeIndex.test_dti_constructor_with_non_nano_dtype  sK    |$$>#bOOOE0$7t5111
 G##d1g"%%%Qd555@@DD
	
 =<)<<<(88444 999>++E22==bAAH
fh///V < < <EJJJ
gx00000r(   c                |   t          j                    }t          j                    }t          ddgd          }|j        dk    sJ |d         |                    d          z
  }|d         |                    d          z
  }|t          j        d          k    sJ d|             |t          j        d          k    sJ d|             |                    t          j
                            d	d
                     t          j        d          }||k     sJ d|             ||k     sJ d|             d S )Nnowtodayr   rg   r   sr   zThe difference is z)result may not exactly match [now, today]F)rK  strict)seconds)r   rc  rd  r   r5   r   rC   	TimedeltarR  r6   rP  rQ  )r"   rS  rc  rd  r$   diff0diff1	tolerances           r&   ,test_dti_constructor_with_non_nano_now_todayz>TestDatetimeIndex.test_dti_constructor_with_non_nano_now_today
  sc   moo!!w/w???|w&&&&q	CKK,,,q	EMM#...Q''')Ee)E)E'''Q''')Ee)E)E'''
 	KB5   	
 	
 	

 L+++	y   ">u">">   y   ">u">">     r(   c                    t          j        dt           j        gt           j                  }|                    t
                    }t          |d          }t          |d          }t          j        ||           d S )Nr   rg   r   r   )	r   r9   r   float64r   r   r   r    r!   )r"   rP   arr2dti1dti2s        r&   5test_dti_constructor_object_float_matches_float_dtypezGTestDatetimeIndex.test_dti_constructor_object_float_matches_float_dtype"  sl    h26{"*555zz&!!SU+++Te,,,
dD)))))r(   r   zM8[us, US/Pacific]c                   t          j        dd          dz  }t          j        j        |d<   |                    t           j                  }t           j        |d<   |                    t                    }t          j        |d<   |                    t                    }t          ||          }t          ||          }t          ||          }t          ||          }	t          |
                    d                    }
|j        -|
                    d                              |j                  }
t          j        ||
           t          j        ||
           t          j        ||
           t          j        |	|
           d S )NrI   r   rg     r   r   r,   )r   arangerC   rD   valuer   rn  r   r   r   r   r   r   r   r    r!   )r"   r5   vals1vals2vals3vals4res1res2res3res4r%   s              r&   <test_dti_constructor_with_dtype_object_int_matches_int_dtypezNTestDatetimeIndex.test_dti_constructor_with_dtype_object_int_matches_int_dtype+  sU    	!4(((4/6<aRZ((6aV$$ 6aV$$U%000U%000U%000U%000 H!5!5667++E22==dgFFH
dH---
dH---
dH---
dH-----r(   )I__name__
__module____qualname__r'   r=   rG   r6   rP  parametrizer   rC   timedelta_rangerQ   r\   re   ri   ro   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   int32int64r   r   r   rx   ry   r   r   r   r   r   r   r   r9   r   rD  r  r  r  r  r  r  r"  r$  r&  r)  r
   r0  r7  r<  rA  rG  rV  ra  rl  rr  r  r   r(   r&   r   r   $   s       0 0 0< < <
N 
N 
N [J|Q<dKKKBw222	
 	# 	# 	#3 3 3", , , 1 1 1 	) 	) 	)4 4 4" [

	gw/7*1U1UV ) )	 ) [

	gw/7*1U1UV  	 4f# f# f#Pl! l! l!\k- k- k-ZR R R   [V|nxxa7K7K6L%MNN  ON0 0 00 0 0 %P %P %PN [VdG_55;@ ;@ 65;@z- - -+ + +0 [Wvrx&BCC/ / DC/2 2 25 5 5 [!H344If!6777:		
 E E E [T#M#M#MNN. . ON.
0 
0 
0 [Wum&<==[URXwwrxv/N/N/NPT$UVV[	57OP " "	  WV >="" " "0 0 0.0 0 00 0 00 0 040 0 0<	0 	0 	0/ / /
0 0 0 [ x ..l0C0CD 2 2 2 [W|5J&KLL* * ML*$) ) ) [XK'899  :9 [W|5J&KLL' ' ML'
 [E,	
  [Yu66[YM(BCC! ! DC 76 !0 [T#>#>#>??1 1 @?14? ? ?0* * * [Wx1E&FGG. . HG. . .r(   r   c                      e Zd Zd Zd Zd Zd Zd Zd Ze	j
                            dg d          d	             Zd
 Zd ZdS )TestTimeSeriesc                l    t          ddd          }t          |          }|j        |j        k    sJ d S Nr   z1/2/20005minrA   )r   r   rB   )r"   r:  r;  s      r&   &test_dti_constructor_preserve_dti_freqz5TestTimeSeries.test_dti_constructor_preserve_dti_freqK  s>    Zf===S!!x49$$$$$$r(   c                    t          ddd          }t          |d           }|j        J t          |j        d           }|j        J d S r  )r   r   rB   rN   )r"   r:  r$   s      r&   test_explicit_none_freqz&TestTimeSeries.test_explicit_none_freqQ  s^    Zf===s...{"""syt444{"""""r(   c                    t          g d          }t          j        g d|          }t          j        t          |          |           d S )N)z1970-01-01 00:00:00.00000000z1970-01-01 00:00:00.00000001z1970-01-01 00:00:00.00000002)r   r+      rg   )r   r   r9   r    r!   )r"   any_int_numpy_dtyper   rP   s       r&   test_dti_constructor_small_intz-TestTimeSeries.test_dti_constructor_small_int[  s\      
 
 h{{{*=>>>
mC00#66666r(   c                L    t          dg          }|d         j        dk    sJ d S )Nz1-1-2000 00:00:01r   r   )r   second)r"   r:  s     r&   test_ctor_str_intradayz%TestTimeSeries.test_ctor_str_intradayh  s0    01221v}!!!!!!r(   c                   t          j        dddt           j                                      d          }t	          |          }|j        t          |t          j        d                    k                                    sJ d S )Nr   d   r+   rg   zM8[D]zM8[ns])	r   ru  r  r   r   rn   r   r5   all)r"   rP   r   s      r&   &test_index_cast_datetime64_other_unitsz5TestTimeSeries.test_index_cast_datetime64_other_unitsl  sr    i3"(33388AACjj
1#RXh=O=OPPPPUUWWWWWWWr(   c                   t          j        dt           j                  }t          |d          }d|dd<   |j        dd         dk                                    sJ t          j        dt           j                  }t          |d          }d|dd<   |j        dd         dk                                    sJ d S )	Nrt  rg   F)copy2   r  T)r   ru  r  r   r   r  )r"   rP   rH   s      r&   test_constructor_int64_nocopyz,TestTimeSeries.test_constructor_int64_nocopyr  s    iBH---c...BsF
2c6"b(--/////iBH---c---BsF
2c6"b(--///////r(   rB   )MEQEYEr   r   bhminre  msr   r   r-   Cc                    t          d|d          }t          ||          }t          j        ||           t          d|dd          }t          ||d          }t          j        ||           d S )Nz2001/02/01 09:00r   )r   rB   r/   rA   r   )r   rB   r   r/   r   r9  )r"   rB   orgr   s       r&   !test_from_freq_recreate_from_dataz0TestTimeSeries.test_from_freq_recreate_from_data  s    
 1aHHHCd+++
c3'''$4L!
 
 
 Cd|<<<
c3'''''r(   c                   g d}d}t          j        t          |          5  t          |           d d d            n# 1 swxY w Y   g d}t          |          }t	          ddd          ddd	g}t          |          }t          t	          ddd                    ddd	g}t          |          }t          j        g dd
          }t          |          }t          ddgd          }t          ddgdd          }t          j	        ||           |||fD ]&}	|j
        |	j
        k                                    sJ 'd S )N)1/1/20051/2/2005z
Jn 3, 2005
2005-01-04z9(\(')?Unknown datetime string format(:', 'Jn 3, 2005'\))?r1   )r  r  1/3/2005r  r  r   r  r  r  r   rg   z
12/05/2007z
25/01/2008T)dayfirstz
2007/05/12z
2008/01/25F)r  	yearfirst)r6   r7   r8   r   r   r   r   r9   r    r!   rn   r  )
r"   rP   r<   r3  r4  r5  r6  idx5idx6others
             r&   #test_datetimeindex_constructor_miscz2TestTimeSeries.test_datetimeindex_constructor_misc  s   BBBJ]:S111 	 	#	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 A@@S!!a##Z\JS!!$1--..
JUS!!hIIIQTUUUS!!lL9DIII<(5D
 
 
 	dD)))D$' 	7 	7EK5</44666666	7 	7s   >AAc                6   d}t          dddd          }t          dddd          }t          |gdd	
          }t          |g          }t          j        ||           t          |gdd	          }t          |g          }t          j        ||           d S )Nz5/10/16i  r+   rI   r   r   r     T)r   r  )r   r  )r   r   r    r!   )r"   r#   dfirstyfirstresult1	expected1r`  	expected2s           r&   <test_dti_constructor_object_dtype_dayfirst_yearfirst_with_tzzKTestTimeSeries.test_dti_constructor_object_dtype_dayfirst_yearfirst_with_tz  s    4Q<8884RL999,FFF!6(++	
gy111,$GGG!6(++	
gy11111r(   N)r  r  r  r  r  r  r  r  r  r6   rP  r  r  r  r  r   r(   r&   r  r  J  s        % % %# # #7 7 7" " "X X X0 0 0 [RRR 	( 	(	 	(7 7 762 2 2 2 2r(   r  )"
__future__r   r   r   r   	functoolsr   operatorr	   rx   r  dateutil.tzr
   numpyr   r6   pandas._libs.tslibsr   r   pandasrC   r   r   r   r   r   r   pandas._testing_testingr    pandas.core.arraysr   r   r  r   r(   r&   <module>r     s   " " " " " "         
                                    
                          + + + + + +c. c. c. c. c. c. c. c.L!m2 m2 m2 m2 m2 m2 m2 m2 m2 m2r(   