o
    5c]                     @   sL  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Zd dlmZmZ d dl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mZ er\d dlZG d	d
 d
Z G dd dZ!dd Z"dd Z#e
j$%dd dge
j$%ddde	&ddde dddd dd d ej'dgdd Z(e
j$%dd dge
j$%dd dgd!d" Z)d gZ*erz	d e+d#gZ*W n
 ej,y   Y nw e
j$%de*e
j$%d$d%d&d'd(e dddddd d d d)d fe dddddd d dd)dfgd*d+ Z-e
j$%dd ge
j$%d,e dddddd d d dfe dddddd d dd-fgd.d/ Z.dS )0    )datetime	timedeltatimezone)partial
attrgetterN)OutOfBoundsDatetimeastype_overflowsafe)PY39)DatetimeIndexIndex	Timestamp
date_rangeoffsetsto_datetime)DatetimeArrayperiod_arrayc                
   @   sP  e Zd Zejdeejgdd Z	ejde
ddddejd	dd
gdd Zdd Zdd Zdd Zdd Zdd Zejdddiddidddgdd Zejdddiddidddgdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zejd0d1d2gd3d4 Zd5d6 Zejdee j!e j"gd7d8 Z#d9d: Z$d;d< Z%d=d> Z&ejdd?d@e'(d@e)dAd@dBj*gdCdD Z+ejdg dEdFdG Z,dHdI Z-ejdJe.egejdKe j/e0e j/edLe1gejdMdNdOgdPdQ Z2dRdS Z3dTdU Z4dVdW Z5dXdY Z6dZd[ Z7d\d] Z8d^d_ Z9d`da Z:dbdc Z;d?S )dTestDatetimeIndexdt_clsc                 C   s   d}t jt|d |tjtdgdd W d    n1 sw   Y  t jt|d |tjtdjgdd W d    d S 1 sCw   Y  d S )NQInferred frequency None from passed values does not conform to passed frequency Dmatch
2011-01-01Dfreq)pytestraises
ValueErrorpdNaTr   value)selfr   msg r$   f/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/tests/indexes/datetimes/test_constructors.pytest_freq_validation_with_nat(   s   "z/TestDatetimeIndex.test_freq_validation_with_natindex
2016-01-01   
US/Pacificperiodstzz1 Dayr,   c                 C   s<   |j }|g d }|jd u sJ ||}|jd u sJ d S )N)r               )_datar   _shallow_copy)r"   r'   arrayarrresultr$   r$   r%   %test_shallow_copy_inherits_array_freq8   s
   

z7TestDatetimeIndex.test_shallow_copy_inherits_array_freqc                 C   sl   t tjdddgdd}||jfD ]#}t|}t|}t|}|||fD ]}t |}t|| q&qd S )N
2015-01-01z1999-04-06 15:14:13
US/Easternr-   )	r   r   r    r3   CategoricalIndexCategoricalSeriestmassert_index_equal)r"   dtidtobjcicarrcserobjr7   r$   r$   r%   test_categorical_preserves_tzJ   s   


z/TestDatetimeIndex.test_categorical_preserves_tzc                 C   s   t jddgdd}tjtdd t| W d    n1 sw   Y  tjtdd t| W d    n1 s:w   Y  tjtdd tt| W d    n1 sWw   Y  tjtdd tt| W d    d S 1 suw   Y  d S )N2016Q12016Q2Qr   zPeriodDtype data is invalidr   )r   PeriodIndexr   r   	TypeErrorr   r   r   )r"   datar$   r$   r%    test_dti_with_period_data_raises[   s   

"z2TestDatetimeIndex.test_dti_with_period_data_raisesc                 C   s   t jdgdd}d}tjt|d t| W d    n1 s w   Y  tjt|d t| W d    n1 s;w   Y  tjt|d tt| W d    n1 sYw   Y  tjt|d tt| W d    d S 1 sxw   Y  d S )Nr   zm8[ns]dtypez3timedelta64\[ns\] cannot be converted to datetime64r   )	npr5   r   r   rL   r   r   r   TimedeltaIndex)r"   rM   r#   r$   r$   r%   %test_dti_with_timedelta64_data_raisesk   s   

"z7TestDatetimeIndex.test_dti_with_timedelta64_data_raisesc                 C   sn   t dt dg}tj|}d}tjt|d t|}W d    n1 s&w   Y  t|}t	|| d S )Nz2012-05-01T01:00:00.000000z2016-05-01T01:00:00.000000zwill store that array directlyr   )
r   r   arraysSparseArrayr?   assert_produces_warningFutureWarningr   r   r@   )r"   valuesr6   r#   r7   expectedr$   r$   r%   "test_constructor_from_sparse_array{   s   
z4TestDatetimeIndex.test_constructor_from_sparse_arrayc              
   C   sX   t tdddtdd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20130101r/   r.   r:   r+   20130103nsr,   r   )dtdttzdt_with_nulldtns)	r   	DataFramer   r   r    r`   rP   r-   zone)r"   dfr$   r$   r%   test_construction_caching   s   
z+TestDatetimeIndex.test_construction_cachingkwargsr-   zdtype.tzrP   rP   r-   c                    sJ   |}t ddd|d  fdd| D }t fi |}t | d S )Nr[   r)   Hr,   r   r-   c                       i | ]\}}|t | qS r$   r   .0keyvalir$   r%   
<dictcomp>       z@TestDatetimeIndex.test_construction_with_alt.<locals>.<dictcomp>)r   itemsr   r?   r@   )r"   rg   tz_aware_fixturer-   r7   r$   rp   r%   test_construction_with_alt   s
   z,TestDatetimeIndex.test_construction_with_altc                    s   |}t ddd|d  d   fdd| D }d|v r8t jdd	|d }t fi |}t|| t d jdd	} d d}t|| d
}t	j
t|d t d j jdd W d    d S 1 sqw   Y  d S )Nr[   r)   ri   rj   c                    rk   r$   r   rl   rp   r$   r%   rr      rs   zLTestDatetimeIndex.test_construction_with_alt_tz_localize.<locals>.<dictcomp>r-   UTCr;   -cannot supply both a tz and a dtype with a tzr   r*   rh   )r   
_with_freqrt   r   asi8
tz_convertr?   r@   tz_localizer   r   r   rP   )r"   rg   ru   r-   r7   rY   i2r#   r$   rp   r%   &test_construction_with_alt_tz_localize   s   
"z8TestDatetimeIndex.test_construction_with_alt_tz_localizec                 C   s  t tdtdgdd}ttdtdgdd}tj||dd t|ts'J |jd u s.J t tddd	td
dd	gdd}ttdtd
gddd}tj||dd t|tsZJ |jd usaJ |j|jksiJ t tddd	tddd	gdd}ttdtdgddd}tj||dd t|tsJ |jd usJ |j|jksJ t tdtd
dd	gdd}t tdtd
dd	gddd}tj||dd t|trJ t tddd	td
dd	gdd}t tddd	td
dd	gddd}tj||dd t|trJ t tdgdd}ttdgdd}tj||dd t|ts#J |jd u s+J t tddd	gdd}ttdgddd}tj||dd t|tsPJ |jd usXJ |j|jksaJ d S Nr   
2011-01-02idxnameTexact2011-01-01 10:00
Asia/Tokyor;   2011-01-02 10:00r-   r   r:   2011-08-01 10:00object)rP   r   )r   r   r   r?   r@   
isinstancer-   r"   r7   expr$   r$   r%   ,test_construction_index_with_mixed_timezones   s   









z>TestDatetimeIndex.test_construction_index_with_mixed_timezonesc                 C   s@  t tjtdtjtdgdd}ttjtdtjtdgdd}tj||dd t|ts/J |jd u s6J t tjtddd	tjtd
dd	gdd}ttjtdtjtd
gddd}tj||dd t|tsjJ |jd usqJ |j|jksyJ t tddd	tjtddd	gdd}ttdtjtdgddd}tj||dd t|tsJ |jd usJ |j|jksJ t tjtdtjtd
dd	gdd}t tjtdtjtd
dd	gddd}tj||dd t|trJ t tjtddd	tjtd
dd	gdd}t tjtddd	tjtd
dd	gddd}tj||dd t|tr%J t tjtjgdd}ttjtjgdd}tj||dd t|tsIJ |jd u sQJ t	t
 t tjtjgddd}W d    n	1 smw   Y  ttjtjgddd}tj||dd t|tsJ |jd usJ |j|jksJ d S r   )r   r   r    r   r   r?   r@   r   r-   rV   rW   r   r$   r$   r%   5test_construction_index_with_mixed_timezones_with_NaT!  s   

	



	



	


zGTestDatetimeIndex.test_construction_index_with_mixed_timezones_with_NaTc              
   C   s  t tdtdgdd}t tdtdgdd}tj||dd t|t s'J t tddd	td
dd	gdd}t tdtd
gddd}tj||dd t|t sSJ t tddd	tddd	gdd}t tdtdgddd}tj||dd t|t sJ d}tjt|d t tddd	td
dd	gdd W d    n1 sw   Y  tjt|d t tdtd
dd	gddd W d    n1 sw   Y  tjt|d t tddd	td
dd	gddd W d    n1 sw   Y  tjt|d: tt	 t
tjtdtjtd
dd	gddd W d    n1 s"w   Y  W d    d S W d    d S 1 s;w   Y  d S )Nr   r   r   r   Tr   r   r   r;   r   r   r:   r   z!cannot be converted to datetime64r   )r   r   r?   r@   r   r   r   r   rV   rW   r   r   r    )r"   r7   r   r#   r$   r$   r%   *test_construction_dti_with_mixed_timezones  s   





	





 $z<TestDatetimeIndex.test_construction_dti_with_mixed_timezonesc                 C   s   t dtjt dg}tt|t| ttt|tt| tj	tjt dg}tt|t| ttt|tt| d S )Nr   z
2011-01-03)
r   r   r    r?   r@   r   r   rQ   r5   nan)r"   r6   r$   r$   r%   "test_construction_base_constructor  s    $z4TestDatetimeIndex.test_construction_base_constructorc                 C   s   t dddt dddt dddt dddg}t|td}tt|| d}tjt|d t| W d    d S 1 s=w   Y  d S )	Ni  r2   i  i  ip  rO   z&Out of bounds .* present at position 0r   )	r   r   r   r?   r@   r   r   r   r   )r"   datesr   r#   r$   r$   r%   test_construction_outofbounds   s   




"z/TestDatetimeIndex.test_construction_outofboundsc                 C   sd   t dddt dddt dddg}t|t dj}t|t d}tg ddd}t|| d S )	Ni  
         	   r   )z
2013-10-07z
2013-10-08z
2013-10-09B)r   r   r   BDayrX   r?   r@   )r"   r   rM   r7   rY   r$   r$   r%   test_construction_with_ndarray  s
   "z0TestDatetimeIndex.test_construction_with_ndarrayc                 C   s   t dd}t |dg}t|d}tdgdd}t|| td  t|dd}W d    n1 s9w   Y  tdgdd}d S )Nz2000-01-01 00:00:00r]   i8
US/Centralz2000-01-01T00:00:00r;   rw   )	rQ   
datetime64r5   viewr   r|   r?   r@   rV   )r"   ro   rX   r7   rY   r$   r$   r%   -test_integer_values_and_tz_interpreted_as_utc  s   z?TestDatetimeIndex.test_integer_values_and_tz_interpreted_as_utcc           	      C   sd  t ddd}t ddd}t|| d}tjt|d t dddd	 W d    n1 s-w   Y  d
}tjt|d td W d    n1 sJw   Y  dd tdD }t|}tdd tdD }t|| t	g d}t|}t|
d}t|| t|j}t|| t	g d}t|}t|
d}t|| t|j}t|| d}tjt|d tg ddd W d    n1 sw   Y  d}tjt|d t ddd W d    n1 sw   Y  tjt|d t ddd W d    n	1 sw   Y  tjt|d t ddd W d    d S 1 s+w   Y  d S )N1/1/2000g      %@r.   r   z!periods must be a number, got foor   foor   startr,   r   z8DatetimeIndex\(\.\.\.\) must be called with a collectionc                 s   s$    | ]}t d ddt| V  qdS )  r2   Nr   r   rm   rq   r$   r$   r%   	<genexpr>6  s   " z>TestDatetimeIndex.test_constructor_coverage.<locals>.<genexpr>c                 S   s    g | ]}t d ddt| qS )r   r2   r   r   r$   r$   r%   
<listcomp>9  s     z?TestDatetimeIndex.test_constructor_coverage.<locals>.<listcomp>)
2000-01-01
2000-01-02z
2000-01-03O)r   r   r    r   )r   r   z
2000-01-04r   zVOf the four parameters: start, end, periods, and freq, exactly three must be specifiedr   b)r   r   r   )endr   r^   )r   r?   r@   r   r   rL   r   rangerQ   r5   astyperz   r   )	r"   rngr   r#   genr7   rY   strings	from_intsr$   r$   r%   test_constructor_coverage(  sZ   


$z+TestDatetimeIndex.test_constructor_coverager   ASW-SUNc                 C   sD  t dd|d}t dd|tdd}t|| t dd|dd}t|j|j t d	d
|d}t dd|tdd}t|| t dd|dd}t|j|j t dd|d}t dd|tdd}t|| t dd|dd}t|j|j t dd|d}t dd|tdd}t|| t dd|dd}t|j|j d S )Nz2013-01-01T00:00:00-05:00z2016-01-01T23:59:59-05:00r   z2013-01-01T00:00:00z2016-01-01T23:59:59ir   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   pytzFixedOffsetr?   r@   assert_numpy_array_equalrz   )r"   r   r   rY   expected_i8r$   r$   r%   $test_constructor_datetime64_tzformatb  sh   z6TestDatetimeIndex.test_constructor_datetime64_tzformatc                 C   s2  t ddgdd}t ddgd}t|| t ddgdd}t|| t ddgdd}d}tjt|d t |d	d W d    n1 sGw   Y  d
}tjt|d t |dd W d    n1 sfw   Y  d}tjt|d t |ddd W d    n1 sw   Y  t |dd}t|| d S )Nz
2013-01-01z
2013-01-02zdatetime64[ns, US/Eastern]rO   r:   r;   zNcannot supply both a tz and a timezone-naive dtype \(i\.e\. datetime64\[ns\]\)r   datetime64[ns]zDdata is already tz-aware US/Eastern, unable to set specified tz: CETzdatetime64[ns, CET]rx   CET)r-   rP   )r   r|   r?   r@   r   r   r   rL   )r"   r   rY   r#   r7   r$   r$   r%   test_constructor_dtype  s2   z(TestDatetimeIndex.test_constructor_dtypec                 C   sH   d}t jt|d tddg|d W d    d S 1 sw   Y  d S )NzUnexpected value for 'dtype'r   r2   r0   rO   r   r   r   r   )r"   rP   r#   r$   r$   r%   %test_constructor_invalid_dtype_raises  s   "z7TestDatetimeIndex.test_constructor_invalid_dtype_raisesc                 C   s"   t ddddd}|jdksJ d S )Nr   r2   ATEST)r   r,   r   r   )r   r   )r"   r   r$   r$   r%   test_constructor_name  s   z'TestDatetimeIndex.test_constructor_namec                 C   s*   t d}t|g}|jd |jksJ d S )Nl   )b0Z4 r   )r   r   
nanosecond)r"   t1r   r$   r$   r%   test_000constructor_resolution  s   
z0TestDatetimeIndex.test_000constructor_resolutionc                 C   sR   t dgdd}d}tjt|d td|_W d    d S 1 s"w   Y  d S )N2010rw   r;   zCannot directly set timezoner   r*   )r   r   r   AttributeErrorr   r   r-   r"   rA   r#   r$   r$   r%   test_disallow_setting_tz  
   "z*TestDatetimeIndex.test_disallow_setting_tzNAmerica/Los_Angeles2000r;   c                 C   s^   t ddd}t ddd}td|||d}tddgddd}t|| td|ju s-J d S )Nz2013-01-01 06:00:00r   r;   z2013-01-02 06:00:00r   )r   r   r   r-   )r-   r   )r   r   r   r?   r@   r   r   r-   )r"   r-   r   r   r7   rY   r$   r$   r%   "test_constructor_start_end_with_tz  s   z4TestDatetimeIndex.test_constructor_start_end_with_tz)r*   r:   r   c                 C   s4   t d|dj}tdg|d}t||ju sJ d S )Nr   r;   )r   r-   r   r   r   )r"   r-   non_norm_tzr7   r$   r$   r%   )test_constructor_with_non_normalized_pytz  s   z;TestDatetimeIndex.test_constructor_with_non_normalized_pytzc                 C   sL   t dddt dddg}t|}t|d  |d  g}t|| d S )Nz2016-10-30 03:00:00+0300zEurope/Helsinkir;   z2016-10-30 03:00:00+0200r   r2   )r   r   to_pydatetimer?   r@   )r"   tsr7   rY   r$   r$   r%   #test_constructor_timestamp_near_dst  s   

z5TestDatetimeIndex.test_constructor_timestamp_near_dstklassboxrO   z	tz, dtype)r*   zdatetime64[ns, US/Pacific])Nr   c                 C   s:   t d|d}|||jg|d}||g}||ksJ d S )Nz
2018-01-01r;   rO   r   r!   )r"   r   r   r-   rP   r   r7   rY   r$   r$   r%   test_constructor_with_int_tz  s   
z.TestDatetimeIndex.test_constructor_with_int_tzc                 C   s,   |}d}t |g|djd }||ksJ d S )Nl     _S r;   r   )r   rz   )r"   tz_naive_fixturer-   r7   rY   r$   r$   r%   test_construction_int_rountrip  s   z0TestDatetimeIndex.test_construction_int_rountripc                 C   s|   t tdddtdddddd}tjdtt|i|d}|d	 }td
d |j	D }tg ddd}t
|| d S )Nr   r2     MSzAustralia/Melbourner   rM   )r'   Yc                 S   s   g | ]	}|j d ddqS )   r2   )monthday)replace)rm   xr$   r$   r%   r   #  s    zYTestDatetimeIndex.test_construction_from_replaced_timestamps_with_dst.<locals>.<listcomp>)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   rc   r   lenresamplemeanr   r'   r?   r@   )r"   r'   testr7   rY   r$   r$   r%   3test_construction_from_replaced_timestamps_with_dst  s   

zETestDatetimeIndex.test_construction_from_replaced_timestamps_with_dstc                 C   sR   t dddd}d}tjt|d t|dd W d    d S 1 s"w   Y  d S )	Nr(   r/   r   r+   z?data is already tz-aware US/Central, unable to set specified tzr   r   r;   )r   r   r   rL   r   r   r$   r$   r%   *test_construction_with_tz_and_tz_aware_dti1  r   z<TestDatetimeIndex.test_construction_with_tz_and_tz_aware_dtic                 C   s@   t j }tddg|d}ttd|dtjg}t|| d S )N2018r    r;   )	dateutilr-   tzlocalr   r   r   r    r?   r@   )r"   r-   r7   rY   r$   r$   r%   &test_construction_with_nat_and_tzlocal8  s   
z8TestDatetimeIndex.test_construction_with_nat_and_tzlocalc                 C   s   t ddgdddd}d}tdd	d
d
dj|dd}t|ddd}t|| d}tdd	dd
dj|dd}t|ddd}t|| d S )Nz2020-11-01 01:00:00z2020-11-02 01:00:00z datetime64[ns, America/New_York]r   F)rP   r   	ambiguouszAmerica/New_Yorki     r2   )yearr   r   hour)r   r0   )r   r,   r   )r   r,   r   )r   r   r|   r   r?   r@   )r"   rY   r   r   r7   r   r$   r$   r%   +test_constructor_with_ambiguous_keyword_arg>  s$   z=TestDatetimeIndex.test_constructor_with_ambiguous_keyword_argc                 C   s   d}t dj|dd}t|ddd}tt d|d	t d
|d	g}t|| t dj|dd}t|ddd}tt d|d	t d|d	g}t|| d S )NzEurope/Warsawz2015-03-29 02:30:00shift_forward)nonexistentr0   ri   r   z2015-03-29 03:00:00+02:00r;   z2015-03-29 04:00:00+02:00)r   r,   r   z2015-03-29 01:00:00+01:00)r   r|   r   r   r?   r@   )r"   r   r   r7   rY   r   r$   r$   r%   -test_constructor_with_nonexistent_keyword_argX  s*   



z?TestDatetimeIndex.test_constructor_with_nonexistent_keyword_argc                 C   s   d}t jt|d tdgdd W d    n1 sw   Y  t jt|d tdgdd W d    d S 1 s:w   Y  d S )Nz with no precision is not allowedr   r   r   rO   )r   r   r   r   r   r"   r#   r$   r$   r%   $test_constructor_no_precision_raisesy  s   "z6TestDatetimeIndex.test_constructor_no_precision_raisesc                 C   sF   d}t jt|d tdgdd W d    d S 1 sw   Y  d S )Nz0Unexpected value for 'dtype': 'datetime64\[us\]'r   r   zdatetime64[us]rO   r   r   r$   r$   r%   'test_constructor_wrong_precision_raises  s   "z9TestDatetimeIndex.test_constructor_wrong_precision_raisesc                 C   sF   t tjtdddtjgtd}ttdddtjg}t	
|| d S )N2019rw   r;   rO   )r   rQ   r5   r   r   r   r   r   r    r?   r@   )r"   r7   rY   r$   r$   r%   Htest_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nan  s    zZTestDatetimeIndex.test_index_constructor_with_numpy_object_array_and_timestamp_tz_with_nan)<__name__
__module____qualname__r   markparametrizer   r   _from_sequence_not_strictr&   r   r   timedelta_ranger8   rG   rN   rS   rZ   rf   rv   r~   r   r   r   r   r   r   r   r   r   r   r   rQ   int32int64r   r   r   r   r   r   r   r-   r   r   r   r   r5   r   listr   r   r   r   r   r   r   r   r   r   r$   r$   r$   r%   r   '   s    




dy]	:
=#

	

!
r   c                   @   s~   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
ejdg ddd Zdd Zdd Zdd ZdS )TestTimeSeriesc                 C   s*   t dddd}t|}|j|jksJ d S Nr   z1/2/20005minr   )r   r   r   )r"   r   rng2r$   r$   r%   &test_dti_constructor_preserve_dti_freq  s   z5TestTimeSeries.test_dti_constructor_preserve_dti_freqc                 C   sb   t dddd}t|d d}|jd u sJ t|jd d}|jd u s"J t|d d}|jd u s/J d S r  )r   r   r   r3   r   )r"   r   r7   dtar$   r$   r%   test_explicit_none_freq  s   z&TestTimeSeries.test_explicit_none_freqc                 C   s   |}t ddd|d}t ddd|d}t ddd|d}t dd	d|d}t dd
d|d}t ddd|d}t dd
d|d}	t ddd|d}
||f||f||f|	|
ffD ]
\}}t|| qPd S )N20142015Mr   z
2014-01-31z
2014-12-31r   z
2014-01-01r9   2020r   z
2019-12-31r   z
2020-01-01)r   r?   r@   )r"   r   r-   rng1	expected1r	  	expected2rng3	expected3rng4	expected4r   rY   r$   r$   r%   test_dti_constructor_years_only  s    z.TestTimeSeries.test_dti_constructor_years_onlyc                 C   s2   t g d}tjg d|d}t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      rO   )r   rQ   r5   r?   r@   )r"   any_int_numpy_dtyper   r6   r$   r$   r%   test_dti_constructor_small_int  s
   z-TestTimeSeries.test_dti_constructor_small_intc                 C   s    t dg}|d jdksJ d S )Nz1-1-2000 00:00:01r   r2   )r   second)r"   r   r$   r$   r%   test_ctor_str_intraday  s   
z%TestTimeSeries.test_ctor_str_intradayc                 C   sD   t dddd}||sJ || sJ || r J d S )N1/1/2005z	12/1/2005r  r   r   r   )r   is_r   copy)r"   rA   r$   r$   r%   test_is_  s   zTestTimeSeries.test_is_c                 C   sF   t jdddt jdd}t|}|jt|t ddk s!J d S )Nr   d   r   rO   zM8[D]zM8[ns])	rQ   aranger  r   r   rX   r	   rP   all)r"   r6   r   r$   r$   r%   &test_index_cast_datetime64_other_units  s   $z5TestTimeSeries.test_index_cast_datetime64_other_unitsc                 C   s   t jdt jd}t|}d|dd< |jdd dk sJ t jdt jd}t|dd}d|dd< |jdd dk s@J d S )Ni  rO   2   r#  T)r!  )rQ   r$  r  r   rz   r%  )r"   r6   r'   r$   r$   r%   test_constructor_int64_nocopy  s   z,TestTimeSeries.test_constructor_int64_nocopyr   )r  rJ   r   r   r   BHTSLUri   NCc                 C   sT   t d|dd}t||d}t|| t d|ddd}t||dd}t|| d S )Nz2001/02/01 09:00r2   r   r   r,   r   r*   )r   r   r-   r,   r   )r   r   r?   r@   )r"   r   orgr   r$   r$   r%   !test_from_freq_recreate_from_data  s   z0TestTimeSeries.test_from_freq_recreate_from_datac                 C   sj  g d}d}t jt|d t| W d    n1 s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
d}t|}tg d}t|}tg d}t|}tddgdd}	tddgddd}
t	
|	|
 |||||fD ]}|j|jk sJ qtddd}tddd}t|ddd}t|dksJ |d |dt   ksJ |jdksJ t||dd}t||tjd d!d}t|t|ksJ |j|jksJ t||d"d}t||tjdd#d}t|t|ksJ |j|jksJ t||d$d}t||tjdd#d}t|t|ks*J |j|jks3J d S )%N)r  1/2/2005z
Jn 3, 2005
2005-01-04z0(\(')?Unknown string format(:', 'Jn 3, 2005'\))?r   )r  r4  1/3/2005r5  r   r2   r4  r6  r5  r   rO   )r  r4  zJan 3, 2005r5  z
12/05/2007z
25/01/2008T)dayfirstz
2007/05/12z
2008/01/25F)r7  	yearfirsti        r   1Br  r1  r   r   r   r  r   )weekdayQS)startingMonthBQ)r   r   r   r   r   r   rQ   r5   r   r?   r@   rX   r%  r   r   r   r   r   WeekQuarterBeginBQuarterEnd)r"   r6   r#   idx1idx2idx3idx4idx5idx6idx7idx8othersdateedater   r$   r$   r%   #test_datetimeindex_constructor_misc  s\   

z2TestTimeSeries.test_datetimeindex_constructor_miscc                 C   s:   t dd}t|td}t| td}t|j|j d S )Nr   z3/1/2000rO   )r   r   r   r   r?   r   rX   )r"   r   r   rY   r$   r$   r%    test_pass_datetimeindex_to_index.  s   
z/TestTimeSeries.test_pass_datetimeindex_to_indexc                 C   sN   t ddd}tjtdd t|ddd W d    d S 1 s w   Y  d S )Nr   r2   zpass as a string insteadr   )r   r)   r  )r   r   r,   )r   r   r   rL   r   )r"   rM  r$   r$   r%   !test_date_range_tuple_freq_raises7  s   "z0TestTimeSeries.test_date_range_tuple_freq_raisesN)r   r   r   r
  r  r  r  r  r"  r&  r)  r   r   r   r3  rN  rO  rP  r$   r$   r$   r%   r    s     
;	r  c                  C   sD   d} t jt| d tddd W d    d S 1 sw   Y  d S )Nz5Valid values for the fold argument are None, 0, or 1.r   {   r0   foldr   r   r   r   )r#   r$   r$   r%   -test_timestamp_constructor_invalid_fold_raise>  s   "rU  c               
   C   s`   d} t d}tjt| d ttddddddd|dd	 W d    d S 1 s)w   Y  d S )
NzBpytz timezones do not support fold. Please use dateutil timezones.Europe/Londonr     r      r      r-   rS  )r   r   r   r   r   r   r   )r#   r-   r$   r$   r%   *test_timestamp_constructor_pytz_fold_raiseF  s
   
 "r[  rS  r2   ts_input    P7-f. gP[YѵCr]   2019-10-27 01:30:00+01:00rW  r   rX  rY  )tzinfoc                 C   sD   d}t jt|d t| |d W d    d S 1 sw   Y  d S )NzCannot pass fold with possibly unambiguous input: int, float, numpy.datetime64, str, or timezone-aware datetime-like. Pass naive datetime-like or build Timestamp from components.r   )r\  rS  rT  )r\  rS  r#   r$   r$   r%   (test_timestamp_constructor_fold_conflictP  s
   "r`  r-   zdateutil/Europe/Londonc              	   C   s0   t ddddd| |d}|j}|}||ksJ d S )NrW  r   rX  r2   rY  )r   r   r   r   minuter-   rS  r   rS  )r-   rS  r   r7   rY   r$   r$   r%   &test_timestamp_constructor_retain_foldg  s   rc  rV  zts_input,fold_out)r]  r   )    pFs. r2   )r^  r   )z2019-10-27 01:30:00+00:00r2   rR  c                 C   s&   t || d}|j}|}||ksJ d S )Nr;   rb  )r-   r\  fold_outr   r7   rY   r$   r$   r%   0test_timestamp_constructor_infer_fold_from_valuez  s   rf  zts_input,fold,value_outrd  c                 C   s(   t || |d}|j}|}||ksJ d S )NrZ  r   )r-   r\  rS  	value_outr   r7   rY   r$   r$   r%   0test_timestamp_constructor_adjust_value_for_fold  s   rh  )/r   r   r   	functoolsr   operatorr   r   numpyrQ   r   r   pandas._libs.tslibsr   r	   pandas.compatr
   pandasr   r   r   r   r   r   r   pandas._testing_testingr?   pandas.core.arraysr   r   zoneinfor   r  rU  r[  r   r   r   utcr`  rc  _tzsZoneInfoZoneInfoNotFoundErrorrf  rh  r$   r$   r$   r%   <module>   s           n 0


	