
    d,                     ,   d dl Z d dlZd dlmZmZ d dlZd dl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mZ d dlmZmZ d dlmZ ej        j        Zd Zd Zd	 Zd
 Z d Z!d Z"ej#        d             Z$d Z%ej        &                    ddej'        gdej(        gdej)        gdej*        gdej'        gdej(        gdej)        gdej*        gdej+        gdej+        gg
          d             Z,d Z-d Z.ej        &                    dddg          d             Z/dS )    N)catch_warningssimplefilter)	Timestamp)	DataFrameHDFStoreIndex
MultiIndexSeries_testingconcat)_maybe_removeensure_clean_store)_test_decoratorsc                 d   t          dddgi          }t          | |z            5 }|                    d|d           |                    d|d           |                    d          j        dk    sJ |                    d          j        dk    sJ 	 d d d            d S # 1 swxY w Y   d S )	NA      afixedformatbtable)r   r   put
get_storerformat_type)tmp_path
setup_pathdfstores       ]/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/pandas/tests/io/pytables/test_put.pytest_format_typer"       s   	C!Q=	!	!B	(Z'	(	( <E		#r'	***		#r'	***$$0G;;;;$$0G;;;;;< < < < < < < < < < < < < < < < < <s   A1B%%B),B)c                     d}t          j        t          |          5  t          | |z  d           d d d            d S # 1 swxY w Y   d S )Nz-format is not a defined argument for HDFStorematchr   r   )pytestraises
ValueErrorr   )r   r   msgs      r!    test_format_kwarg_in_constructorr*   *   s     :C	z	-	-	- 8 8J&w77778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8s   A  AAc                    t          |          5 }t          j                    }t          j        dd          5  t          |d           |                    d|           |                    d          j        rJ d}t          j
        t          |          5  |                    d|           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        dd          5  t          |d           |                    d|           |                    d          j        sJ t          |d           |                    d|           |                    d          j        sJ 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | |z  }t          j                    }t          j        dd          5  |                    |d           t          |          5 }|                    d          j        rJ 	 d d d            n# 1 swxY w Y   t          j
        t          |          5  |                    |dd	           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        dd          5  |                    |d
           t          |          5 }|                    d
          j        sJ 	 d d d            n# 1 swxY w Y   |                    |dd	           t          |          5 }|                    d          j        sJ 	 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 )Nzio.hdf.default_formatr   r   Can only append to Tablesr$   df2r   Tappenddf3df4)r   tmmakeDataFramepdoption_contextr   r   r   is_tabler&   r'   r(   r/   to_hdfr   )r   r   r    r   r)   paths         r!   test_api_default_formatr9   3   s   	J	'	' 356@@ 	( 	(%&&&IIdB''--6666-Cz555 ( (UB'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 6@@ 	3 	3%&&&IIdB##D))2222%'''LL#####D))22222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	33 3 3 3 3 3 3 3 3 3 3 3 3 3 3* j D				B		2G	<	< 0 0
		$d^^ 	7u''--66666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7]:S111 	0 	0IIdE$I///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
	2G	<	< 4 4
		$d^^ 	4u##E**33333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4
		$d	+++d^^ 	4u##E**33333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	44 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4s2  )FA CB<0C<C  CC CFC	FC	F3BF9FF			FF		FF #F &J:H$J$H(	(J+H(	,J
I/#J/I3	3J6I3	7JJ
J
&&M*K6*M*6K:	:M*=K:	>*M*(MM*M	M*M	M**M.1M.c                    t          |           5 }t          j                    }t          j                    }||d<   |d d         |d<   |d d         |d<   |d d         |d<   |d d         |d<   |                    d|d d         d	           d
}t          j        t          |          5  |                    d|dd          d           d d d            n# 1 swxY w Y   t          |d           t          j        t          |          5  |                    d|dd          d           d d d            n# 1 swxY w Y   t          j        t          |          5  |                    d|dd          d           d d d            n# 1 swxY w Y   |                    d|d d         dd           t          j	        |d d         |d                    d d d            d S # 1 swxY w Y   d S )Nr   
   r   zfoo/bar/bahfooz/foocr   r   r,   r$   Tr.   fF)r   r/   )
r   r2   makeTimeSeriesmakeTimeDataFramer   r&   r'   r(   r   assert_frame_equal)r   r    tsr   r)   s        r!   test_putrC   ]   s   	J	'	' 35  !##c
Wc
!#2#wm#2#we3B3f		#r#2#ww	/// *]:S111 	1 	1IIc2bcc74I000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1
 	eS!!!]:S111 	1 	1IIc2bcc74I000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 ]:S111 	1 	1IIc2bcc74I000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 			#r#2#wwu	===
b"guSz22273 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s   BG,-!CG,C	G,!C	".G,!D=1G,=E	G,E	G,#!FG,F	G,F	AG,,G03G0c                    t          |           5 }t          d t          d          D                       }t          t	          j        d          |          }t          ||d          }||d<   t          j        |d         |           ||d<   t          j	        |d         |           t          dgd t          d          D             z             }t          t	          j        d	          |          }t          ||d          }||d<   t          j        |d         |           ||d<   t          j	        |d         |           d d d            d S # 1 swxY w Y   d S )
Nc                     g | ]}d | S zI am a very long string index:  .0is     r!   
<listcomp>z)test_put_string_index.<locals>.<listcomp>~   s!    PPP<<<PPP       index)r   Br   r   $abcdefghijklmnopqrstuvwxyz1234567890c                     g | ]}d | S rF   rG   rH   s     r!   rK   z)test_put_string_index.<locals>.<listcomp>   s!    HHH444HHHrL      )
r   r   ranger
   nparanger   r2   assert_series_equalrA   )r   r    rO   sr   s        r!   test_put_string_indexrY   |   s   	J	'	' .5PPeBiiPPPQQ29R==...QQ''((c

uSz1---c

eCj"--- 34HHeBiiHHHI
 
 29R==...QQ''((c

uSz1---c

eCj"----. . . . . . . . . . . . . . . . . .s   D;EEEc                    t          |           5 }t          j                    }|                    d|dd           t          j        |d         |           d}t          j        t          |          5  |                    d|dd           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   zlibr   complib0Compression not supported on Fixed format storesr$   r   r   )r   r2   r@   r   rA   r&   r'   r(   )r   r    r   r)   s       r!   test_put_compressionr_      s<   	J	'	' 	?5!##		#r'6	:::
eCj"--- A]:S111 	? 	?IIc2gvI>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s6   A%B35BB3B	B3"B	#B33B7:B7c                    t          j                    }t          |           5 }d}t          j        t
          |          5  |                    d|dd           d d d            n# 1 swxY w Y   |                    d|dd           t          j        |d         |           d d d            d S # 1 swxY w Y   d S )	Nr^   r$   r   r   bloscr\   r=   r   )r2   r@   r   r&   r'   r(   r   rA   )r   r   r    r)   s       r!   test_put_compression_bloscrb      sL   				B	J	'	' .5@]:S111 	@ 	@IIc2gwI???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 			#r'7	;;;
eCj"---. . . . . . . . . . . . . . . . . .s5   B3A'B3'A+	+B3.A+	/7B33B7:B7c                 <   t          j                    }d|d<   d|d<   |d         dk    |d<   |d         dk    |d	<   d
|d<   d|d<   d|d<   t          d          |d<   t          d          |d<   t          j        ddddd          |d<   t          j        ddddd          |d<   t          j        |j        |j        dd         dgf<   |                                }t          |           5 }t          |d           t          d
          5  t          dt          j        j                   |                    d|           d d d            n# 1 swxY w Y   |                    d          }t          j        ||           d d d            d S # 1 swxY w Y   d S )Nr<   obj1barobj2r   r   bool1rP   bool2Tbool3r   int1r   int220010102
timestamp120010103
timestamp2i  	datetime1   	datetime2   r   )recordignore)r2   r@   r   datetimerU   nanlocrO   _consolidater   r   r   r   r4   errorsPerformanceWarningr   getrA   )r   r   r    expecteds       r!   test_put_mixed_typer~      s   				BBvJBvJS'A+BwKS'A+BwKBwKBvJBvJ ,,B| ,,B|'aAq99B{O'aAq99B{O&(fBF28AaC=6("#			B	J	'	' 	,5eT""" 4((( 	  	 29#?@@@IIdB	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  99T??
h+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s6   ,!F6EFE	FE	-FFFzformat, indexr   r   c                    t          |           5 }t          t          j                            dd          t          d                    } |t          |                    |_        t          |d           |	                    d||           t          j        ||d                    d d d            d S # 1 swxY w Y   d S )Nr;   r   ABcolumnsr   r   )r   r   rU   randomrandnlistlenrO   r   r   r2   rA   )r   r   rO   r    r   s        r!   test_store_index_typesr      s    & 
J	'	' /5ryr1--tDzzBBB5R>>eT"""		$6	***
b%+.../ / / / / / / / / / / / / / / / / /s   BB::B>B>c                 X   t          j        g dddg          }t          t          j        d                              dd          |          }|                    |j                                                  }t          |           5 }|
                    d	|           t          j        |d	         |d
d
           |
                    d|d           t          j        |d         |d
d
           t          j        d          }t          j        t"          |          5  |
                    d|ddg           d d d            n# 1 swxY w Y   t          j        d          }t          j        t"          |          5  |
                    d|dd
           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |           5 }|                    d|           |                    d|           t          j        |d         t'          ||f                     d d d            n# 1 swxY w Y   t          t          j        d                              dd          t)          t+          d          d                    }|                    |j                                                  }t          |           5 }|
                    d|d           t          j        |d         |d
d
           d d d            d S # 1 swxY w Y   d S )N))r   r   )r   r   )rP   r   )rP   r   firstsecondnames   rq      r   r   T)check_index_typecheck_column_typedf1r   r   z<cannot use a multi-index on axis [1] with data_columns ['A']r$   r-   r   )r   data_columnsz;cannot use a multi-index on axis [1] with data_columns Truer0   ABCDr<   )name)r	   from_tuplesr   rU   rV   reshapeset_axisrO   to_numpyr   r   r2   rA   reescaper&   r'   r(   r/   r   r   r   )r   rO   r   r}   r    r)   s         r!   test_column_multiindexr      sj    "888(@S  E 
29R==((A..	>	>	>B{{28,,..//H	J	'	' D5		$
$KDD	
 	
 	
 	
 			%G	,,,
%L(TT	
 	
 	
 	
 iVWW]:S111 	E 	EIIeRseIDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	EiUVV]:S111 	D 	DIIeRdICCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	DD D D D D D D D D D D D D D D& 
J	'	' >5UBUB
eElFB8,<,<===	> > > > > > > > > > > > > > > 
29R==((A..d6llQV8W8W8W	X	X	XB{{28,,..//H	J	'	' 
5		%G	,,,
%L(TT	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   BG'EGE	GE	2GF."G.F2	2G5F2	6GG	G	AII	I7LL#&L#c           	         t          |           5 }dd}t          |d           t          t          j        d          ddg |                      }|                    d|           t          j        |                    d          |           t          |d           t          t          j        d          ddg |g d                    }|                    d|           t          j        |                    d          |           t          |d           t          t          j        d	           |g d          
          }|                    d|           t          t          j        d	           |g d          
          }t          j
        |                    d          |           t          |d           t          t          j        d          ddg |g d                    }d}t          j        t          |          5  |                    d|           d d d            n# 1 swxY w Y   t          |d           t          t          j        d          ddg |g d                    }t          j        t          |          5  |                    d|           d d d            n# 1 swxY w Y   t          |d           t          t          j        d          ddg |g d                    }|                    d|           t          j        |                    d          |           d d d            d S # 1 swxY w Y   d S )Nc                 ^    t          j        d t          dd          D             |           S )Nc           	          g | ]?}t          d           D ]-}t          d          D ]}t          j        dd|          ||f.@S )r   rq   i  r   )rT   rv   )rI   drX   ts       r!   rK   z=test_store_multiindex.<locals>.make_index.<locals>.<listcomp>  sx       "1XX  "1XX	   &tR33Q:    rL   r   rq   r   )r	   r   rT   r   s    r!   
make_indexz)test_store_multiindex.<locals>.make_index  sE    ) "1a[[      rL   r   )r   r   r   r   )r   rO   )dateNNrX   r   rN   )r   level_1level_2)r   r   r   zBduplicate names/columns in the multi-index when storing as a tabler$   )r   r   r   )r   rX   r   )N)r   r   r   rU   zerosr/   r2   rA   selectr
   rW   r&   r'   r(   )r   r    r   r   rX   xpr)   s          r!   test_store_multiindexr     sK    
J	'	' A65		 		 		 		 	eT"""rx((3*JJLLQQQT2
ell400"555 	eT"""HW#J*11122
 
 

 	T2
ell400"555 	eS!!!28B<<zz2F2F2F'G'GHHHS!BHRLL

3Q3Q3Q(R(RSSS
u||C00"555 	eT"""HW#J*///00
 
 

 S]:S111 	# 	#LLr"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	eT"""HW#J*55566
 
 

 ]:S111 	# 	#LLr"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	eT"""HW#J*///00
 
 

 	T2
ell400"555CA6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6 A6s\   HMH;/M;H?	?MH?	AM"K9MK			MK		BMM #M r   c                    t          t          j                            dd          t	          j        ddd                    }| |z  }|                    |dd|	           t	          j        |d          }t          j	        ||           d S )
N   r   20220101M)freqperiodsrN   r   w)moder   )
r   rU   r   r   r4   period_ranger7   read_hdfr2   rA   )r   r   r   r   r8   r}   s         r!   test_store_periodindexr   ^  s     

	1R_ZcST%U%U%U
 
 
B j DIIdDs6I222{4&&H"h'''''rL   )0rv   r   warningsr   r   numpyrU   r&   pandas._libs.tslibsr   pandasr4   r   r   r   r	   r
   r   r2   r   pandas.tests.io.pytables.commonr   r   pandas.utilr   tdmark
single_cpu
pytestmarkr"   r*   r9   rC   rY   r_   skip_if_windowsrb   r~   parametrizemakeFloatIndexmakeStringIndexmakeIntIndexmakeDateIndexmakePeriodIndexr   r   r   r   rG   rL   r!   <module>r      s    				       
      ) ) ) ) ) )                             / . . . . .[#
< < <8 8 8'4 '4 '4T3 3 3>. . .4
? 
? 
? 
. 
. 
., , ,8 	"#$	"$%	"/"	""#	"#$	"$%	"/"	""#	"$%	"$% 
/ 
/ 
/+
 +
 +
\D6 D6 D6N GW#566
( 
( 76
( 
( 
(rL   