
    bMh6                        d dl 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mZ d dlmZmZ d dlmZ ej        j        gZd Zd Zd Zd	 Zd
 Zd Zej         d             Z!d Z"d Z#d Z$d Z%ej        &                    dddg          ej        &                    d e
d  e'd          D                        e
 ej(        de)                     e
 ej(        d                     edd           ej*        dd          g          d                         Z+d Z,d Z-ej        &                    dddg          d             Z.dS )    N)	Timestamp)	DataFrameHDFStoreIndex
MultiIndexSeries_testingconcat
date_range)_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       a/var/www/html/test/jupyter/venv/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          dt          j        d                              d          z  t          t          d                    t          d t          d          D                                 }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          dt          j        d                              d          z  t          t          d                    t          d t          d          D                                 }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 )Ng?x   )      ABCDc                     g | ]}d | S zi- .0is     r    
<listcomp>z+test_api_default_format.<locals>.<listcomp>5   s    555aa555    r,   columnsindexzio.hdf.default_formatr   r   Can only append to Tablesr#   df2r   c                     g | ]}d | S r0   r1   r2   s     r    r5   z+test_api_default_format.<locals>.<listcomp>N   s    111!X!XX111r6   )keyT)r=   appenddf3df4)r   r   nparangereshaper   listrangepdoption_contextr   r   r   is_tabler%   r&   r'   r>   to_hdfr   )r   r   r   r   r(   paths         r    test_api_default_formatrK   /   sx   	J	'	' 35")C..((111$v,,''5559955566
 
 
 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 32 j D	binn$$W---d6ll##11uRyy11122
 
 
B 
	2G	<	< 4 4
		$D	!!!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 	4 	4IIddI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 
	2G	<	< 4 4
		$E	"""d^^ 	4u##E**33333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4
		$E$	///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 4s4  BHA D8>D!D8!D%%D8(D%)D8,H8D<	<H?D<	 HBG*H*G.	.H1G.	2HHH'MK/#M/K3	3M6K3	7ML:.M:L>	>ML>	MMM1'P6O6P6O	P6	O	
*P64PP6P"	"P6%P"	&P66P:=P:c           
         t          |           5 }t          t          j        dt          j                  t          dd                    }t          t          j                            d          	                    d          t          t          d                    t          d	d
d                    }||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 )N
   dtype
2020-01-01periodsr9   r   )   r-   r.   
2000-01-01rT   BrR   freqr7   r   r   zfoo/bar/bahfooz/foocr   r   r:   r#   T)r>   fF)r   r>   )r   r   rA   rB   float64r   r   randomdefault_rngstandard_normalr   rD   r   r%   r&   r'   r   tmassert_frame_equal)r   r   tsr   r(   s        r    test_putrc   a   sp   	J	'	' !35Ib
+++:lTV3W3W3W
 
 
 I!!!$$44W==$v,,''\2C@@@
 
 

 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2C!3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3 !3s   D!I01!EI0E"	"I0%E"	&.I0!G5I0G	I0G		I0'!HI0H	I0H	AI00I47I4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: r1   r2   s     r    r5   z)test_put_string_index.<locals>.<listcomp>   s!    PPP<<<PPPr6   rT   rS   )r   rV   r   r   $abcdefghijklmnopqrstuvwxyz1234567890c                     g | ]}d | S rf   r1   r2   s     r    r5   z)test_put_string_index.<locals>.<listcomp>   s!    HHH444HHHr6      )
r   r   rE   r   rA   rB   r   r`   assert_series_equalra   )r   r   r9   sr   s        r    test_put_string_indexrl      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           
      2   t          |           5 }t          t          j                            d                              d          t          t          d                    t          ddd                    }|	                    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   rM   r-   r.   rU   rM   rV   rW   r7   rZ   r   zlibr   complib0Compression not supported on Fixed format storesr#   r   r   )r   r   rA   r]   r^   r_   r   rD   r   r   r`   ra   r%   r&   r'   )r   r   r   r(   s       r    test_put_compressionrs      s   	J	'	' ?5I!!!$$44W==$v,,''\2C@@@
 
 
 			#r'6	:::
eCj"--- A]:S111 	? 	?IIc2gvI>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?s6   B>DC4(D4C8	8D;C8	<DDDc           	      2   t          t          j                            d                              d          t          t          d                    t          ddd                    }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   rn   r.   rU   rM   rV   rW   r7   rr   r#   r   r   bloscrp   rZ   r   )r   rA   r]   r^   r_   r   rD   r   r   r%   r&   r'   r   r`   ra   )r   r   r   r(   s       r    test_put_compression_bloscrv      s   	
	a  0099d6ll##r<<<
 
 
B 
J	'	' .5@]:S111 	@ 	@IIc2gwI???	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 			#r'7	;;;
eCj"---. . . . . . . . . . . . . . . . . .s6   <DC 4D C	DC	7DDDc                 d   t          dt          d                              d          gz            }t          |           5 }|                    d|           |                                }|                    d          }t          j        ||           d d d            d S # 1 swxY w Y   d S )N   20010102nsser)	r   r   as_unitr   r   copygetr`   rj   )r   r{   r   expectedresults        r    test_put_datetime_serr      s    
i
++33D99::
;
;C	J	'	' 15		%88::5!!
vx000	1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   AB%%B),B)c           	      V   t          t          j                            d                              d          t          t          d                    t          ddd                    }d	|d
<   d|d<   |d         dk    |d<   |d         dk    |d<   d|d<   d|d<   d|d<   t          d          	                    d          |d<   t          d          	                    d          |d<   t          d          	                    d          |d<   t          d          	                    d          |d<   t          j
        |j        |j        dd         d
gf<   |                                }t          |           5 }t          |d           |rd nt           j        j        }t'          j        |          5  |                    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   rn   r.   rU   rM   rV   rW   r7   rY   obj1barobj2r   r   bool1bool2Tbool3r   int1int2ry   rz   
timestamp120010103
timestamp2	datetime1	datetime2rx      r   )r   rA   r]   r^   r_   r   rD   r   r   r|   nanlocr9   _consolidater   r   rF   errorsPerformanceWarningr`   assert_produces_warningr   r~   ra   )r   using_infer_stringr   r   warningr   s         r    test_put_mixed_typer      s   	
	a  0099d6ll##r<<<
 
 
B
 BvJBvJS'A+BwKS'A+BwKBwKBvJBvJ ,,44T::B| ,,44T::B|
++33D99B{O
++33D99B{O&(fBF28AaC=6("#			B	J	'	' ,5eT""",N$$")2N'00 	  	 IIdB	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  99T??
h+++, , , , , , , , , , , , , , , , , ,s6   ?:H9GHG 	 H#G 	$-HH"%H"c                    t          j        | }t          dt          j        dt           j        dg|          i          }t          |           5 }t          |d           |                    d|           |j        t          j
        u rdnd}|                    |          }|                    d          }t          j        ||           d d d            d S # 1 swxY w Y   d S )Nr   xyrN   r   strstring)rF   StringDtyper   arrayNAr   r   r   na_valuerA   r   astyper~   r`   ra   )r   string_dtype_argumentsrO   r   r   expected_dtyper   r   s           r    test_put_str_framer      s   N23E	C3s"35AAAB	C	CB	J	'	' 05eT"""		$"'.BF":":99^,,4
fh///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s   A=CC!Cc                    t          j        | }t          dt           j        dg|          }t	          |           5 }t          |d           |                    d|           |j        t          j	        u rdnd}|
                    |          }|                    d          }t          j        ||           d d d            d S # 1 swxY w Y   d S )Nr   r   rN   r   r{   r   r   )rF   r   r   r   r   r   r   r   rA   r   r   r~   r`   rj   )r   r   rO   r{   r   r   r   r   s           r    test_put_str_seriesr      s	   N23E
#ruc"%
0
0
0C	J	'	' 15eT"""		%"'.BF":":::n--5!!
vx0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   A=CC
C
r   r   r   r9   c                 ,    g | ]}t          |          S r1   )r   r2   s     r    r5   r5     s    )))!s1vv)))r6   rM   rN   rP   rQ   c                 z   t          |           5 }t          t          j                            d                              d          t          d          |          }t          |d           |                    d||           t          j
        ||d                    d d d            d S # 1 swxY w Y   d S )Nr   )rM   r   ABr7   r   r   )r   r   rA   r]   r^   r_   rD   r   r   r`   ra   )r   r   r9   r   r   s        r    test_store_index_typesr     s     
J	'	' /5I!!!$$44W==JJ
 
 

 	eT"""		$6	***
b%+.../ / / / / / / / / / / / / / / / / /s   BB00B47B4c                    t          j        g dddg          }t          t          j        d                              dd          |          }|                    |j                                                  }t          |           5 }|rYd	}t          j        t          |
          5  |                    d|           d d d            n# 1 swxY w Y   	 d d d            d S |                    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   )rV   r   )rV   r   firstsecondnames   rx   r-   )r8   z=Saving a MultiIndex with an extension dtype is not supported.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   data_columnsz;cannot use a multi-index on axis [1] with data_columns Truer?   r.   rY   )name)r   from_tuplesr   rA   rB   rC   set_axisr9   to_numpyr   r%   r&   NotImplementedErrorr   r`   ra   reescaper'   r>   r
   r   rD   )r   r   r9   r   r   r   r(   s          r    test_column_multiindexr   "  s+    "888(@S  E 
29R==((A..	>	>	>B{{28,,..//H	J	'	' D5 	QC2#>>> $ $		$###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $D D D D D D D D 			$
$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2 
J	'	' >5UBUB
eElFB8,<,<===	> > > > > > > > > > > > > > > 
29R==((A..d6llQV8W8W8W	X	X	XB{{28,,..//H	J	'	' 
5		%G	,,,
%L(TT	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s    H -CH C	H C	H )BH F)H )F-	-H 0F-	12H #H	=H 	H	H H	H  H$'H$:AJJ!$J!67M::M>M>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          dd          }t          j        |t          d          t          d          g|           }|S )Nz
2013-12-01z
2013-12-02r   rx   r   )r   r   from_productrE   )r   dtimis      r    
make_indexz)test_store_multiindex.<locals>.make_index[  s>    \<88C(#uQxxq)B%PPPBIr6   r   )r   r   r   r   r7   )dateNNr{   r   rS   )r   level_1level_2)r   r   tzBduplicate names/columns in the multi-index when storing as a tabler#   )r   r   r   )r   rk   r   )N)r   r   r   rA   zerosr>   r`   ra   selectr   rj   r%   r&   r'   )r   r   r   r   r{   xpr(   s          r    test_store_multiindexr   V  s8    
J	'	' ;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 	eU###RXb\\4H4H4H)I)IJJJUC   BHRLL

3Q3Q3Q(R(RSSS
u||E22B777 	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5w;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6 ;6s\   HMH;/M;H?	?MH?	AM"K9MK			MK		BMM #M c                 B   t          t          j                            d                              d          t          j        ddd                    }| |z  }|                    |dd	|
           t          j        |d          }t          j
        ||           d S )Nr   )   r   20220101Mr   )rX   rR   rS   r   w)r=   moder   )r   rA   r]   r^   r_   rF   period_rangerI   read_hdfr`   ra   )r   r   r   r   rJ   r   s         r    test_store_periodindexr     s     

	a  0088ojsA>>>
 
 
B
 j DIId3vI666{4&&H"h'''''r6   )/r   numpyrA   r%   pandas._libs.tslibsr   pandasrF   r   r   r   r   r   r	   r`   r
   r   pandas.tests.io.pytables.commonr   r   pandas.utilr   tdmark
single_cpu
pytestmarkr!   r)   rK   rc   rl   rs   skip_if_windowsrv   r   r   r   r   parametrizerE   rB   floatr   r   r   r   r   r1   r6   r    <module>r      s   				      ) ) ) ) ) )    	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	        / . . . . .k$%
< < <8 8 8/4 /4 /4d"3 "3 "3J. . .4? ? ?" . . ."1 1 1, , ,>0 0 01 1 1 GW#566))uuRyy)))**ibi%((())ibimm
<,,,b111	 	/ /	 	 76/1
 1
 1
h>6 >6 >6B GW#566( ( 76( ( (r6   