
    Pie                         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
Z
mZ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 G d d          Z G d d          Z G d d          ZdS )    N)IncompatibleFrequency)Pandas4Warning)PeriodDtype)IndexNaTPeriodPeriodIndexSeries
date_rangeoffsetsperiod_range)PeriodArrayc                   
   e Zd Zej                            dg d          d             Zej                            dg d          d             Zej                            dg d          d             Zej                            d	g d
          d             Z	ej        
                    d          ej        
                    d          ej                            dg d          d                                     ZdS )TestPeriodIndexDisallowedFreqszfreq,freq_depr))2M2ME)2Q-MARz2QE-MAR)2Y-FEBz2YE-FEB)r   2me)r   z2qe-MAR)r   z2yE-febc                 (   d| }t          j        t          |          5  t          ddg|           d d d            n# 1 swxY w Y   t          j        t          |          5  t	          dd|           d d d            d S # 1 swxY w Y   d S )NInvalid frequency: match
2020-01-01
2020-01-02freqstartendr   )pytestraises
ValueErrorr	   r   )selfr   	freq_deprmsgs       /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/indexes/period/test_constructors.py1test_period_index_offsets_frequency_error_messagezPTestPeriodIndexDisallowedFreqs.test_period_index_offsets_frequency_error_message   sH    0I//]:S111 	F 	F|49EEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F ]:S111 	O 	O|INNNN	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	Os#   AAA'BBBr   )2SME2sme2BYE2Bye2CBMEc                 (   d| }t          j        t          |          5  t          dd|           d d d            n# 1 swxY w Y   t          j        t          |          5  t	          ddg|           d d d            d S # 1 swxY w Y   d S Nr   r   z2020-01z2020-05r   r!   r"   r#   r   r	   )r$   r   r&   s      r'   (test_period_index_frequency_invalid_freqzGTestPeriodIndexDisallowedFreqs.test_period_index_frequency_invalid_freq-   s!    +D**]:S111 	: 	:ID9999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:]:S111 	; 	;I.T::::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;#   A  AA&BBB)z2BQE-SEPz2BYE-MAR2BMEc                     d| }t          dd|          }t          j        t          |          5  |                                 d d d            d S # 1 swxY w Y   d S )Nr   z01-Jan-2012   periodsr   r   )r   r!   r"   r#   	to_period)r$   r   r&   rngs       r'   2test_period_index_from_datetime_index_invalid_freqzQTestPeriodIndexDisallowedFreqs.test_period_index_from_datetime_index_invalid_freq:   s     +D**===]:S111 	 	MMOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAr%   )2T1l2Unc                 (   d| }t          j        t          |          5  t          dd|           d d d            n# 1 swxY w Y   t          j        t          |          5  t	          ddg|           d d d            d S # 1 swxY w Y   d S r/   r0   )r$   r%   r&   s      r'    test_period_index_T_L_U_N_raisesz?TestPeriodIndexDisallowedFreqs.test_period_index_T_L_U_N_raisesC   s5    0I//]:S111 	? 	?II>>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?]:S111 	@ 	@I.Y????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@r2   3ignore:PeriodDtype\[B\] is deprecated:FutureWarningz*ignore:Period with BDay freq:FutureWarning))2W2w)z2W-FRIz2w-fri)2D2d)2B2bc                    d|dd           d}t          j        t          |d          5  t          ddg|          }d d d            n# 1 swxY w Y   t          ddg|          }t          j        ||           t          j        t          |d          5  t          dd|	          }d d d            n# 1 swxY w Y   t          dd|	          }t          j        ||           d S )
N'   z8' is deprecated and will be removed in a future version.F)r   raise_on_extra_warningsr   r   r   r   )tmassert_produces_warningr   r	   assert_index_equalr   )r$   r   r%   r&   resultexpecteds         r'   *test_period_index_depr_lowercase_frequencyzITestPeriodIndexDisallowedFreqs.test_period_index_depr_lowercase_frequencyM   s    X	!""WWW 	 '#u
 
 
 	O 	O !,!=INNNF	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O
 l;$GGG
fh///'#u
 
 
 	X 	X ",YWWWF	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X
  l4PPP
fh/////s#   AAAB99B= B=N)__name__
__module____qualname__r!   markparametrizer(   r1   r:   r@   filterwarningsrQ        r'   r   r      sx       [	
 	
 	

 
O O
 
O [111 ; ;	 ; [V%E%E%EFF  GF [[*A*A*ABB@ @ CB@ [ VWW[ LMM[HHH 0 0	  NM XW0 0 0rY   r   c                   h   e Zd Zd Zd Zd Zej                            de	e
j        eej        g          d             Zd Zd 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 Zd Zd Zej                            dddg e
j        ddg          g          d             Zd Z d Z!ej                            dg d          ej                            dg d           d!                         Z"ej                            dg d           d"             Z#d# Z$d$ Z%d% Z&d& Z'ej                            d'g d(          ej        (                    d)          ej        (                    d*          d+                                     Z)d, Z*d-S ).TestPeriodIndexc                     t          dd           t          dd           t          j        g dd          }t          j        t          j        g d          d          }t          j        ||           d S )NiYordinalr   r   )r   rJ   )ordinalsr   )r   r	   from_ordinalsnparrayrL   rN   )r$   idx1idx2s      r'   test_from_ordinalsz"TestPeriodIndex.test_from_ordinalsk   s}    u3''''qs####(***3GGG("(:::2F2FSQQQ
dD)))))rY   c                    t          dd          t          t          dd          g}t          j        t	          |          t          |                     t          j        t	          t          j        |                    t          t          j        |                               t          j        t          t          dd          g}t          j        t	          |          t          |                     t          j        t	          t          j        |                    t          t          j        |                               t          dd          t          t          dd          g}t          j        t	          |          t	          |t                               t          j        t	          t          j        |                    t	          t          j        |          t                               d S )N2011-01Mr   2011-03Ddtype)
r   r   rL   rN   r   r	   rc   rd   nanobject)r$   arrs     r'   "test_construction_base_constructorz2TestPeriodIndex.test_construction_base_constructors   su   ic***C	1L1L1LM
eCjj+c*:*:;;;
eBHSMM22K4N4NOOOvsF937778
eCjj+c*:*:;;;
eBHSMM22K4N4NOOOic***C	1L1L1LM
eCjj%6*B*B*BCCC
eBHSMM22E"(3--v4V4V4VWWWWWrY   c                     t          d          }g d}t          ||          }t          ||          }t          j        ||           d S )Nrl   )
2011-01-01z
2012-03-04z
2014-05-01rm   )r   r   r	   rL   rN   )r$   rn   valuesrO   rP   s        r'   'test_base_constructor_with_period_dtypez7TestPeriodIndex.test_base_constructor_with_period_dtype   sW    C  ;;;vU+++vU333
fh/////rY   values_constructorc                     t          dd          t          t          dd          g} ||          }t          |t                    }t	          |          t          u sJ t          j        |j        t          j	        |                     d S )Nri   rj   r   rk   rm   )
r   r   r   rp   typerL   assert_numpy_array_equalru   rc   rd   )r$   rw   r7   ru   rO   s        r'   test_index_object_dtypez'TestPeriodIndex.test_index_object_dtype   s     93'''93'''

 $#G,,vV,,,F||u$$$$
#FM28F3C3CDDDDDrY   c                    d}t          j        t          |          5  t          dd          }d d d            n# 1 swxY w Y   d}t          j        t          |          5  t	          ddd          }d d d            n# 1 swxY w Y   t          j        t          |          5  t	          |d	          }d d d            n# 1 swxY w Y   t          j        ||           d S )
N#Period with BDay freq is deprecatedr   z4/2/2012Br   PeriodDtype\[B\] is deprecated
   r   r7   r   r   r7   )rL   rM   FutureWarningr   r   rN   )r$   msg1pmsg2rP   indexs         r'   test_constructor_use_start_freqz/TestPeriodIndex.test_constructor_use_start_freq   s   4'TBBB 	- 	-z,,,A	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-0'TBBB 	L 	L#*bsKKKH	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 'TBBB 	6 	6 q"555E	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6
eX.....s3   <A A $BB
B)CCCc                    t          j        dd                              d          dd         }t          j        t          j        dd          d          dd         }t	          j        ||d	
          }t          ddd	          }t          j        ||           t	          j        ||d
          }t          j	        |j
        |j
                   t	          j        ||          }t          j        ||           g d}ddg}d}t          j        t          |          5  t	          j        ||d           d d d            n# 1 swxY w Y   t          j        t          |          5  t	          j        ||d           d d d            n# 1 swxY w Y   g d}g d}t	          j        ||d          }t          ddd          }	t          j        ||	           d S )Ni  i        rJ         Q-DECyearquarterr   1990Q32009Q2r   z2Q-DECr   r   )  r   r   zMismatched Period array lengthsr   rj   )r   monthr   r   )rJ   r      2007-01r   r6   )rc   arangerepeattiler	   from_fieldsr   rL   rN   rz   asi8r!   r"   r#   )
r$   yearsquartersr   rP   index2monthsr&   idxexps
             r'   test_constructor_field_arraysz-TestPeriodIndex.test_constructor_field_arrays   s}    	$%%,,Q//"5729Q??B//"5'UH7SSS(AAA
eX...(eXHUUU
#EJ<<<'UHEEE
eX..."""Q/]:S111 	H 	H#f3GGGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H]:S111 	I 	I#f4HHHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I #""%5SIII9ac:::
c3'''''s$   %E		EE/FFFc           	      2   t          t          dd          t          dd          d          }t          t          dd          t          dd          t          dd          t          dd          gd          }t          j        ||           d S )	NrJ   nsr^   r   r   r   r   r   )r   r   r	   rL   rN   r$   r   r   s      r'   test_constructor_nanoz%TestPeriodIndex.test_constructor_nano   s    ...qt,,,
 
 

 qt,,,qt,,,qt,,,qt,,,	 
 
 
 	c3'''''rY   c                    t          j        ddt           j                                      d          }t          j        t          j        g dt           j                  d          }t          j        ||          }t          j	        |j
        t          |                     t          j	        |j        t          |                     d S )Ni    rm   r   )rJ   r   r   r   (   r   )rc   r   int64r   r   rd   r	   r   rL   rN   r   r   r   )r$   r   r   pindexs       r'   %test_constructor_arrays_negative_yearz5TestPeriodIndex.test_constructor_arrays_negative_year   s    	$BH555<<Q??728LLLAAA2FF(eXFFF
fk5<<888
fneHoo>>>>>rY   c           	          d}t          j        t          |          5  t          j        t          dd          t          t          d                    d           d d d            d S # 1 swxY w Y   d S )NzQuarter must be 1 <= q <= 4r   r   i  r   r   r   )r!   r"   r#   r	   r   rangelistr$   r&   s     r'   !test_constructor_invalid_quartersz1TestPeriodIndex.test_constructor_invalid_quarters   s    +]:S111 	 	#4&&U1XXW   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A A++A/2A/c                     d}t          j        t          |          5  t          ddd           d d d            d S # 1 swxY w Y   d S )Nz$periods must be an integer, got 10.5r   r   g      %@rj   r6   )r!   r"   	TypeErrorr   r   s     r'   #test_period_range_fractional_periodz3TestPeriodIndex.test_period_range_fractional_period   s    4]9C000 	< 	<Ds;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<s   >AAc                     t          dd          }t          |d|j                  }t          |d          }t          j        ||           d S )Nz2002-01-01 00:0030minr   r   r   r   )r   r   r   rL   rN   )r$   r   r   rO   s       r'   "test_constructor_with_without_freqz2TestPeriodIndex.test_constructor_with_without_freq   sV    )888
CCCE1555
c6*****rY   c                    t          ddd          }t          j        t          |j                  |           t          j        t          t          |j                            |           d}t          j        t          |          5  t          |j	                   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   d}t          j        t          |          5  t          t          dd	
                     d d d            n# 1 swxY w Y   t          t          |                    }t          j        ||           t          |          }t          j        ||           t          |d
          }t          j        ||           t          |t          j                    
          }t          j        ||           |j        dk    sJ t          |d
          }t          j        ||                    d                     |j        dk    sJ t          |t          j        d          
          }t          j        ||                    d                     |j        dk    sJ t          |d
          }|                    dd          }t          j        ||           d S )Nr   r   rj   r6   z)freq not specified and cannot be inferredr   z'Period' object is not iterable2007r]   r   )dataMEr   r   r   rl   e)r   rL   rN   r	   ru   r   r!   r"   r#   r   r   r   iterr   MonthEndr   asfreq)r$   r   r&   rO   r   s        r'   test_constructor_fromarraylikez.TestPeriodIndex.test_constructor_fromarraylike   sg   9bs;;; 	k#*55s;;;
k$sz*:*:;;SAAA9]:S111 	" 	"!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"]:S111 	( 	(SX'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 0]9C000 	7 	7VF5556666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 T#YY''
fc***S!!
fc***Ss+++
fc***Sw'7'9'9:::
fc***{d""""St,,,
fcjj&6&6777{e####Sw'7':':;;;
fcjj&6&6777{e####Ss+++jjc""
fc*****s6   B,,B03B0"D  DD( EEEc                 ,   t          j        dddt           j                  }|                    t          j        d                    }t          |d          }t          |                    d          d          }t          j        ||           d S )	Ni i d   rm   zM8[us]rl   r   zM8[ns])	rc   r   r   viewrn   r	   astyperL   rN   )r$   valspirP   s       r'   test_constructor_datetime64arrz.TestPeriodIndex.test_constructor_datetime64arr  s    yBHEEEyy(++,,C(((t{{8443???
b(+++++rY   box)Nseriesr   c                     t          ddd          }||j        }n|dk    rt          |          }t          |d          }t          g dd          }t	          j        ||           d S )	N2017r   r   r6   r   rl   r   )z
2017-01-31z
2017-02-28z
2017-03-31z
2017-04-30)r   _valuesr
   r	   rL   rN   )r$   r   r   rO   rP   s        r'   !test_constructor_datetime64arr_okz1TestPeriodIndex.test_constructor_datetime64arr_ok%  s     &!$777;<DDH__$<<DT,,,DDD3
 
 
 	fh/////rY   c                    t          ddgd          }t          ddgd          }t          j        ||           |j        dk    sJ t          ddgd	          }t          ddgd
          }t          j        ||           |j        d	k    sJ t          ddgd          }t          |d          }t          ddgd          }t          j        ||           |j        dk    sJ t          |d          }t          j        ||           |j        dk    sJ d}t	          j        t          |          5  t          dgdd           d d d            d S # 1 swxY w Y   d S )Nz2013-01z2013-03z	period[M]rm   rj   r   z
2013-01-05z
2013-03-05z
period[3D]3Dz
2013-01-01z
2013-01-02rl   z&specified freq and dtype are differentr   ri   z	period[D])r   rn   )r	   rL   rN   rn   r!   r"   r   )r$   r   r   resr&   s        r'   test_constructor_dtypez&TestPeriodIndex.test_constructor_dtype4  s   9i0DDD9i0s;;;
c3'''yK''''<6lKKK<6TBBB
c3'''yL(((( <6SAAA#[1119i0s;;;
c3'''yK''''#C(((
c3'''yK''''6]0<<< 	B 	B#[AAAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs   :EE"Ec                     t          g d          }t          |t                     sJ t          |          dk    sJ |j        dk    sJ t	          j        t          d          5  t          g            d d d            d S # 1 swxY w Y   d S )Nrj   r   r   r   freq not specifiedr   )r	   
isinstancelenr   r!   r"   r#   )r$   r   s     r'   test_constructor_emptyz&TestPeriodIndex.test_constructor_emptyQ  s    "3'''#{+++++3xx1}}}}x4]:-ABBB 	 	OOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   &BB
Bc                    t          t          dd          t          t          dd          g          }t          g dd          }t          j        ||           t          t          j        t          dd          t          t          dd          g                    }t          j        ||           t          t          t          t          dd          t          dd          g          }t          g dd          }t          j        ||           t          t          j        t          t          t          dd          t          dd          g                    }t          j        ||           t          t          t          ddgd          }t          j        ||           t          j        t          d          5  t          t          t          g           d d d            n# 1 swxY w Y   t          j        t          d          5  t          t          j        t          t          g                     d d d            n# 1 swxY w Y   t          j        t          d          5  t          ddg           d d d            n# 1 swxY w Y   t          j        t          d          5  t          t          j        ddg                     d d d            d S # 1 swxY w Y   d S )	Nri   rj   r   ri   r   ri   )r   r   ri   ri   r   r   r   )
r	   r   r   rL   rN   rc   rd   r!   r"   r#   r   s      r'   test_constructor_pi_natz'TestPeriodIndex.test_constructor_pi_natZ  s   IC(((#vic/J/J/JK
 
 777cBBB
c3'''HfYS1113ys8S8S8STUU
 
 	c3'''#vic222F934O4O4OP
 
 >>>SIII
c3'''Hc6)#666ys8S8S8ST 
 

 	c3'''3Y	:EEE
c3''']:-ABBB 	$ 	$c
###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ ]:-ABBB 	. 	.#s,,---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. ]:-ABBB 	( 	('''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( ]:-ABBB 	2 	2%00111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2sH   G66G:=G:.III<JJ!J $K11K58K5c                    d}t          j        t          |          5  t          t	          dd          t
          t	          dd          g           d d d            n# 1 swxY w Y   t          j        t          |          5  t          t          j        t	          dd          t
          t	          dd          g                     d d d            n# 1 swxY w Y   t          j        t          |          5  t          t
          t	          dd          t	          dd          g           d d d            n# 1 swxY w Y   t          j        t          |          5  t          t          j        t
          t	          dd          t	          dd          g                     d d d            d S # 1 swxY w Y   d S )Nz5Input has different freq=D from PeriodIndex\(freq=M\)r   ri   rj   r   rl   )r!   r"   r   r	   r   r   rc   rd   r   s     r'   test_constructor_incompat_freqz.TestPeriodIndex.test_constructor_incompat_freq  s   G]0<<< 	Y 	Y	444c6)RU;V;V;VWXXX	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y ]0<<< 	 	IC000#vic7R7R7RS   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]0<<< 	Y 	YfYS9996)RU;V;V;VWXXX	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y ]0<<< 	 	&555vic7R7R7RS   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sI   6A  A$'A$ACC!C 6EE	E(AF==GGc                    t          dt          t          dd          g          }t          g dd          }t          j        ||           t          dt          t          dd          g          }t          g dd          }t          j        ||           t          t          dd          t          d	g          }t          g d
d          }t          j        ||           d S )Nri   rj   r   r   r   )r   r   ri   rt   rl   
2012-01-01)rt   r   r   )r	   r   r   rL   rN   r   s      r'   test_constructor_mixedz&TestPeriodIndex.test_constructor_mixed  s    9c6)#+F+F+FGHH777cBBB
c3'''5#vic'B'B'BCDD333#>>>
c3'''6,S9993MNN===CHHH
c3'''''rY   floats皙? @c                     d}t          j        t          |          5  t          |           d d d            d S # 1 swxY w Y   d S )Nz9PeriodIndex does not allow floating point in constructionr   )r!   r"   r   r	   )r$   r   r&   s      r'   test_constructor_floatsz'TestPeriodIndex.test_constructor_floats  s    I]9C000 	  	 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   ;??c                    t          g d          }|dz
  }t          j        ||          }d t          ||          D             }t	          t          t          |                    }t          |          }t          j        ||           d S )N)i  i  i  r   r   c                 8    g | ]}|d          dd|d         dS )r   dQrJ   rX   ).0ts     r'   
<listcomp>zETestPeriodIndex.test_constructor_year_and_quarter.<locals>.<listcomp>  s4    AAA1Q4$$$AaD$$$AAArY   )	r
   r	   r   zipr   mapr   rL   rN   )r$   r   r   r   strslopsr   s          r'   !test_constructor_year_and_quarterz1TestPeriodIndex.test_constructor_year_and_quarter  s    ((())+%4AAAAAc'4.@.@AAAC%%&&
a%%%%%rY   c                    t          ddd          }t          g dd          }t          j        ||           t          ddd	
          }t          g dd	          }t          j        ||           t          ddd          }t          g dd          }t          j        ||           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            n# 1 swxY w Y   d}t	          j        t          |          5  t          ddd           d d d            d S # 1 swxY w Y   d S )N2014-01r   r   r   r   r7   )r   z2014-03z2014-05z2014-07r   
2014-01-02z
2014-01-15r   r   )r   z
2014-01-05z
2014-01-08z
2014-01-11z
2014-01-142014-01-01 17:004hr   )r    r   r7   )z2014-01-01 09:00z2014-01-01 13:00r   z;Frequency must be positive, because it represents span: -1Mr   ri   z-1Mz:Frequency must be positive, because it represents span: 0M0Mr6   )r   r	   rL   rN   r!   r"   r#   )r$   pidxrP   r&   s       r'   test_constructor_freq_multz*TestPeriodIndex.test_constructor_freq_mult  sv   )$BBBKKKRVWWW
dH---,LtLLLRRR
 
 
 	dH--- 2qIIIHHHt
 
 
 	dH---K]:S111 	1 	1%0000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 K]:S111 	0 	0$////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 K]:S111 	: 	:AD9999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s6   C++C/2C/D22D69D6E::E>E>zfreq_offset, freq_period))YEr]   )r   rj   )rl   rl   )minr   )sr   mult)rJ   r   r   r   r   c                     t          |          |z   }t          |          |z   }t          d|d          }t          d|d                              |          }t	          j        ||           d S )N
2014-04-01r   r   )strr   r   r8   rL   rN   )r$   r   freq_offsetfreq_periodfreqstr_offsetfreqstr_periodr   rP   s           r'   %test_constructor_freq_mult_dti_compatz5TestPeriodIndex.test_constructor_freq_mult_dti_compat  s~     T[0T[0,^RPPP^R
 
 

)N
#
# 	 	dH-----rY   c                     t          d| dd          }t          d| dd                              | d          }t          j        ||           d S )Nr  rj   r   r   r   )r   r   r8   rL   rN   )r$   r   r   rP   s       r'   +test_constructor_freq_mult_dti_compat_monthz;TestPeriodIndex.test_constructor_freq_mult_dti_compat_month  sn    ,ZZZLLL[[["
 
 

)tJJJ

 	 	dH-----rY   c                     dD ](}t          ddg|          }t          ddgd          })dD ]<}t          dd|	          }t          dd
gd          }t          j        ||           =d S )N)1D1h1h1Dz
2016-01-01z
2016-01-02r   z2016-01-01 00:00z2016-01-02 00:0025hr   r   z2016-01-02 01:00)r	   r   rL   rN   )r$   r   r   rP   s       r'   test_constructor_freq_combinedz.TestPeriodIndex.test_constructor_freq_combined  s    $ 	Y 	YDl;$GGGD"$68J#KRWXXXHH$ 	2 	2DlADIIID"$68J#KRWXXXH!$1111	2 	2rY   c                    t          ddd          }t          |          dk    sJ t          ddd          }t          |          dk    sJ t          ddd          }t          |          d	k    sJ t          d
dd          }t          |          dk    sJ d}t          j        t          |          5  t          ddd          }d d d            n# 1 swxY w Y   t          |          dk    sJ t          ddd          }t          |          dk    sJ t          ddd          }t          |          dk    sJ t          ddd          }t          |          dk    sJ t          j        t          |          5  t          dd          }t          |d          }d d d            n# 1 swxY w Y   t          |          dk    sJ |j        |j        k    sJ |d         |k    sJ t          dd          }t          |d !          }t          |          d k    sJ |j        |j        k    sJ |d"         |k    sJ d#}t          j        t          |          5  t          dd$          }d d d            n# 1 swxY w Y   t          |d !          }t          |          t          |          k    sJ ||k                                    sJ |j        |j        k    sJ d S )%Nr]   z1/1/2001z	12/1/2009)r   r   r    	   r   $   rj   l   rl   z
12/31/2009i  r}   r   r~   i-	  hz12/31/2001 23:00i8"  Minz1/1/2001 23:59i  r   z1/1/2001 23:59:59iQ 02-Apr-2005r   r   r   
2006-12-31Wr   )r    r7   r`   z:'w' is deprecated and will be removed in a future version.1w)	r   r   rL   rM   r   r   r   r   all)r$   r   r&   r   i1end_intvi2s          r'   test_period_range_lengthz(TestPeriodIndex.test_period_range_length  s   s*+FFF2ww!||||s*+FFF2ww%s*+FFF2ww&    s*,GGG2ww+%%%%3'SAAA 	L 	L3jlKKKB	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L2ww'!!!!s*:LMMM2ww(""""uJ<LMMM2ww'!!!!s*:MNNN2ww,&&&&'SAAA 	7 	7=#..EE2666B	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 2ww"}}}}w%*$$$$!u~~~~,,,h3332ww"}}}}w(-''''"v!!!!J'cBBB 	2 	2lD11H	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2h3332ww#b''!!!!b~~w"'!!!!!!s6   :CC C	"F77F;>F;*JJJc           
      d   d}t          j        t          |          5  t          dd          }t          dd          }t	          ||           t          |t          dd          g          }d d d            n# 1 swxY w Y   t          |          dk    sJ |d	         |k    sJ t          j        t          |          5  t          t          j        |t          dd          g                    }d d d            n# 1 swxY w Y   t          |          dk    sJ |d	         |k    sJ d S )
Nr}   r   r  r~   
2005-05-01)r   r    z
2005-05-05r   r   )	rL   rM   r   r   r   r	   r   rc   rd   )r$   r&   r   r  r  s        r'   "test_infer_freq_from_first_elementz2TestPeriodIndex.test_infer_freq_from_first_element*  s   3'SAAA 	D 	D=#..ElC00Hu(3333 h|S(A(ABCCB	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 2ww!||||!u    'SAAA 	N 	NRXxc1J1J&KLLMMB	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N2ww!||||!u      s$   AA;;A?A?2DD	Dc                    d}t          j        t          |          5  t          dd          }d d d            n# 1 swxY w Y   |t          dd          g}d}d}t	          j        t          |          5  t          j        t          |          5  t          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j	        |          }t	          j        t          |          5  t          j        t          |          5  t          |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	Nr}   r   r  r~   r  r  z9Input has different freq=W-SUN from PeriodIndex\(freq=B\)r   )
rL   rM   r   r   r!   r"   r   r	   rc   rd   )r$   r&   r  r   depr_msgs        r'   test_mixed_freq_raisesz&TestPeriodIndex.test_mixed_freq_raises;  s   3'SAAA 	1 	1lC00H	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 &s334J4]0<<< 	" 	"+MJJJ " "D!!!" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" x~~]0<<< 	" 	"+MJJJ " "D!!!" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"sy   ;??7CB/#C/B3	3C6B3	7CC
C
 ED8,E8D<	<E?D<	 EEEr   )rj   r   r]   rl   r~   r   r   msusr   r  z8ignore:Period with BDay freq is deprecated:FutureWarningrA   c                     t          d|d          }t          |j        |          }t          j        ||           d S )Nz
2001/04/01rJ   r   r   )r   r	   ru   rL   rN   )r$   r   orgr   s       r'   test_recreate_from_dataz'TestPeriodIndex.test_recreate_from_dataL  sE     D!DDD#*4000
c3'''''rY   c                 $   g d}t          |d          }t          d |D                       }|                    t                    }t	          |t                    sJ t          d |D                       sJ t          j        ||           d S )N)i  r   i  r]   r   c                 ,    g | ]}t          |          S rX   )r  )r   nums     r'   r   zDTestPeriodIndex.test_map_with_string_constructor.<locals>.<listcomp>\  s    222s#c((222rY   c              3   @   K   | ]}t          |t                    V  d S )N)r   r  )r   resis     r'   	<genexpr>zCTestPeriodIndex.test_map_with_string_constructor.<locals>.<genexpr>c  s,      99T:dC((999999rY   )r	   r   r   r  r   r  rL   rN   )r$   rawr   rP   r   s        r'    test_map_with_string_constructorz0TestPeriodIndex.test_map_with_string_constructorX  s       Cc***22c22233iinn #u%%%%% 99S99999999 	c8,,,,,rY   N)+rR   rS   rT   rg   rr   rv   r!   rU   rV   r   rc   rd   r	   r   _from_sequencer{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r   r#  rW   r(  r0  rX   rY   r'   r[   r[   j   s^       * * *X X X0 0 0 [tRX{K<VW E E E/ / /( ( (>( ( ("? ? ?  < < <
+ + +(+ (+ (+T, , , [U$=$=$=>>0 0 ?>0B B B:  &2 &2 &2P  0( ( ( [Xc
HBHc3Z4H4H'IJJ    KJ 
& & &: : :> ["	
 	
 	
	 	 [V___55. . 65	 	. [V___55. . 65.2 2 2." ." ."`! ! !"" " "" [LLL  [C  [ VWW( ( XW  (
- - - - -rY   r[   c                       e Zd Zd Zd Zej                            dddg ej	        ddg          g          d             Z
dS )TestSimpleNewc                    t          dddd          }t          j        t          d          5  |                    |d           d d d            n# 1 swxY w Y   |                    |j        d          }t          j        ||           d	}t          j        t          |          5  t          |j                                      t          |j
                  |j        
           d d d            n# 1 swxY w Y   t          |j                                      |j
        |j        
          }|                    |d          }t          j        ||           d S )Nr   r   r   rj   )namer7   r   <class .*PeriodIndex'>r   r5  z Should be numpy array of type i8rm   )r   r!   r"   AssertionError_simple_new_datarL   rN   ry   r   r   rn   )r$   r   rO   r&   rq   s        r'   test_constructor_simple_newz)TestSimpleNew.test_constructor_simple_newj  s   93DDD]>1IJJJ 	+ 	+OOCcO***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 55
fc***0]>555 	J 	JOO''chsy'III	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 39oo))#(#))DD3//
fc*****s$   AAA,AC99C= C=c                     t          g dd          }t          j        t          d          5  |                    |d           d d d            n# 1 swxY w Y   |                    |j        d          }t          j        ||           d S )Nrj   r   )r   r5  r6  r   r7  )r	   r!   r"   r8  r9  r:  rL   rN   )r$   r   rO   s      r'   !test_constructor_simple_new_emptyz/TestSimpleNew.test_constructor_simple_new_empty|  s    "3S111]>1IJJJ 	+ 	+OOCcO***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 55
fc*****s   AAAr   r   r   c                     t          j        t          d          5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nz<class r   )r!   r"   r8  r	   r9  )r$   r   s     r'   -test_period_index_simple_new_disallows_floatsz;TestSimpleNew.test_period_index_simple_new_disallows_floats  s    ]>;;; 	, 	,#F+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   >AAN)rR   rS   rT   r;  r=  r!   rU   rV   rc   rd   r?  rX   rY   r'   r3  r3  i  sz        + + +$+ + + [Xc
HBHc3Z4H4H'IJJ, , KJ, , ,rY   r3  c                        e Zd Zd Zd Zd ZdS )TestShallowCopyc                 ~    t          g d          }|                                }|}t          j        ||           d S )Nrj   r   )r	   _viewrL   rN   )r$   r   rO   rP   s       r'   test_shallow_copy_emptyz'TestShallowCopy.test_shallow_copy_empty  s?    "3'''
fh/////rY   c                     t          ddd          }t          j        t          d          5  |                    |j                   d d d            d S # 1 swxY w Y   d S )N
2018-01-01r   rD   r6   ndarrayr   )r   r!   r"   r8  _shallow_copyr   r$   r   s     r'   test_shallow_copy_disallow_i8z-TestShallowCopy.test_shallow_copy_disallow_i8  s    ,===]>;;; 	& 	&RW%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   AAAc                     t          ddd          }t          j        t          d          5  |                    |           d d d            d S # 1 swxY w Y   d S )NrF  r   rD   r6   r	   r   )r   r!   r"   r8  rH  rI  s     r'   0test_shallow_copy_requires_disallow_period_indexz@TestShallowCopy.test_shallow_copy_requires_disallow_period_index  s    ,===]>??? 	! 	!R   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   AAAN)rR   rS   rT   rD  rJ  rL  rX   rY   r'   rA  rA    sA        0 0 0& & &! ! ! ! !rY   rA  c                       e Zd Zd Zd ZdS )TestSeriesPeriodc                     d}t          j        t          |          5  t          t	          ddd          t
                     d d d            d S # 1 swxY w Y   d S )Nz(Cannot cast PeriodIndex to dtype float64r   z
2000-01-01r   rl   r6   rm   )r!   r"   r   r
   r   floatr   s     r'   !test_constructor_cant_cast_periodz2TestSeriesPeriod.test_constructor_cant_cast_period  s    8]9C000 	R 	R<bsCCC5QQQQ	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	Rs   'AAAc                     t          dd          }t          |t          d                    }t          |          }t          j        ||           d S )Nz1/1/2000r   )r7   rl   rm   )r   r
   r   rL   assert_series_equal)r$   r   serr   s       r'   test_constructor_cast_objectz-TestSeriesPeriod.test_constructor_cast_object  sR    *b111R{3//000Rjj
sC(((((rY   N)rR   rS   rT   rQ  rU  rX   rY   r'   rN  rN    s5        R R R
) ) ) ) )rY   rN  )numpyrc   r!   pandas._libs.tslibs.periodr   pandas.errorsr   pandas.core.dtypes.dtypesr   pandasr   r   r   r	   r
   r   r   r   pandas._testing_testingrL   pandas.core.arraysr   r   r[   r3  rA  rN  rX   rY   r'   <module>r^     s        < < < < < < ( ( ( ( ( ( 1 1 1 1 1 1	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	       * * * * * *P0 P0 P0 P0 P0 P0 P0 P0f|- |- |- |- |- |- |- |-~, , , , , , , ,D! ! ! ! ! ! ! !*
) 
) 
) 
) 
) 
) 
) 
) 
) 
)rY   