
    Mh               
          S SK r S SKJr  S SKrS SKrS SKrS SKJrJ	r	J
r
JrJrJrJrJr  S SKJr  S SKJrJr  \R,                  R.                  rS rS rS rS	 rS
 rS r\R,                  R?                  S\" SSSSS9\" \ " S5      5      /5      S 5       r!S r"S r#S r$\R,                  R?                  SSS/ SS/5      S 5       r%g)    N)BytesIO)CategoricalIndex	DataFrameHDFStoreIndex
MultiIndex_testing
date_rangeread_hdf)ensure_clean_store)Term_maybe_adjust_namec                 r   [        S[        R                  " S5      R                  S5      -  [	        [        S5      [        S9[	        [        S5       Vs/ s H  nSU 3PM
     sn[        S9S9n[        U 5       nUR                  S	U5        S
n[        R                  " [        US9   UR                  S	S/S9  S S S 5        Sn[        R                  " [        US9   UR                  S	S/S9  S S S 5        S S S 5        g s  snf ! , (       d  f       NQ= f! , (       d  f       N-= f! , (       d  f       g = f)N皙?x         ABCDdtyper   i-columnsindexdfzqcannot pass a column specification when reading a Fixed format store. this store must be selected in its entiretymatchA)r   zucannot pass a where specification when reading from a Fixed format store. this store must be selected in its entiretyz	columns=Awhere)r   nparangereshaper   listobjectranger   putpytestraises	TypeErrorselect)
setup_pathir   storemsgs        V/var/www/html/env/lib/python3.13/site-packages/pandas/tests/io/pytables/test_errors.pytest_pass_spec_to_storerr2      s    	biin$$W--d6l&1uRy1y!r!Xy1@
B 
J	'5		$A 	 ]]9C0LLuL- 1H 	 ]]9C0LL{_L5 1 
(	' 2 10 10 
(	'sB   D;.D()D;#D(D0D(
D	D(
D%	!D((
D6c           	      p   [        S/ SQ05      n[        S/ SQ0[        SSS9S9n[        U 5       nUR                  SUS	S
9  [        R
                  " S5      n[        R                  " [        US9   UR                  SUS	SS9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Na)         )r         z1/1/2000r7   periods)r   frametableformatz3incompatible kind in col [integer - datetime64[ns]]r   T)r?   append)	r   r
   r   r(   reescaper)   r*   r+   )r-   df1df2r/   r0   s        r1   $test_table_index_incompatible_dtypesrE   3   s    
S)$
%C
S)$Jz1,M
NC	J	'5		'3w	/iiMN]]9C0IIgs74I@ 1 
(	' 10 
(	's$   AB'2BB'
B$	 B''
B5c                    [        U 5       nS[        R                  " SSS5      4/nU H  u  p4[        S[        R
                  " S5      R                  S5      -  [        [        S5      [        S	9[        [        S
5       Vs/ s H  nSU 3PM
     sn[        S	9S9nXFU'   [        R                  " SU S35      n[        R                  " [        US9   UR!                  SU 3U5        S S S 5        M     S S S 5        [        S[        R
                  " S5      R                  S5      -  [        [        S5      [        S	9[        [        S
5       Vs/ s H  nSU 3PM
     sn[        S	9S9nSUS'   SUS'   [        R                  " SSS5      US'   UR#                  5       n[        U 5       n[        R                  " S5      n[        R                  " [        US9   UR!                  SU5        S S S 5        S S S 5        g s  snf ! , (       d  f       GM  = f! , (       d  f       GN*= fs  snf ! , (       d  f       NF= f! , (       d  f       g = f)Ndatei  r5   r6   r   r   r   r   r   r   r   r   [z&] is not implemented as a table columnr   df1_fooobj1barobj2	datetime1zjCannot serialize the column [datetime1]
because its data contents are not [string] but [date] object dtypedf_unimplemented)r   datetimerG   r   r"   r#   r$   r   r%   r&   r'   rA   rB   r)   r*   r+   r@   _consolidate)r-   r/   dtypesnfr.   r   r0   s           r1   'test_unimplemented_dtypes_table_columnsrU   >   s   	J	'58==q!456 DAbiin,,W55d6l&9uRy9y!r!Xy9HB
 qE))as"HIJCy4tA3Z, 54 	 
(  
biin$$W--d6l&1uRy1y!r!Xy1@
B
 BvJBvJmmD!Q/B{O		B	J	'5iiF
 ]]9C0LL+R0 1 
(	'% : 54 
(	'& 2 10 
(	'sa   A7HHAHH+HH,.0IH11IH
H	H
H)1
H?	;I
Ic                 t   [        U5       n[        [        R                  R	                  S5      R                  S5      [        [        S5      [        S9[        SSSS9S	9nS
US'   SUR                  UR                  SS S4'   UR                  SUSS9  [        R                  " S5      n[        R                   " ["        US9   [%        5         S S S 5        [        R                  " S5      n[        R                   " [&        US9   UR)                  SS5        S S S 5        Sn[        R                   " [*        US9   UR)                  SS5        S S S 5        S S S 5        X-  n[        [        R                  R	                  S5      R                  S5      [        S5      [        SSS9S	9nUR-                  USSSS9  [/        USSS9  [/        USSS9  X-  n[        [        R                  R	                  S5      R                  S5      [        S5      [        SSS9S	9nUR-                  USSS 9  S!n[        R                   " [&        US9   [/        USSS9  S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN`= f! , (       d  f       GN<= f! , (       d  f       GNF= f! , (       d  f       g = f)"Nr6   )
   r   r   r   z
2000-01-01rW   B)r;   freqr   rJ   stringrL   r   r   r   r=   r>   z:__init__() missing 1 required positional argument: 'where'r   zWcannot process expression [df.index[3]], [2000-01-06 00:00:00] is not a valid conditionzdf.index[3]zinvalid syntaxzindex>20130101r:   dfqT)keyr?   data_columnsz0index>Timestamp('20130104') & columns=['A', 'B']r    z
A>0 or C>0)r]   r?   a  The passed where expression: A>0 or C>0\n\s*contains an invalid variable reference\n\s*all of the variable references must be a reference to\n\s*an axis \(e.g. 'index' or 'columns'\), or a data_column\n\s*The currently defined references are: index,columns\n)r   r   r"   randomdefault_rngstandard_normalr   r%   r&   r
   locr   r(   rA   rB   r)   r*   r+   r   
ValueErrorr,   SyntaxErrorto_hdfr   )tmp_pathr-   r/   r   r0   pathr\   s          r1   test_invalid_termsrh   c   s<   	J	'5II!!!$44W=$v,f5\2C@

 8*/rxx!}h&'		$7	+ iiTU]]9C0F 1 ii=
 ]]:S1LL}- 2 ]];c2LLx( 33 
(:  D

		a 009VR0C
 JJtwTJB T5 RST5-  D

		a 009VR0C
 JJtwJ/	A  
z	-uL1 
.	-Y 10 21 323 
(	'r 
.	-s`   B9JI!7JI3#J=JJJ)!
I0	+J3
J	=J
J	J
J&)
J7c                    [        [        R                  R                  S5      R	                  S5      5      n[        S[        R                  R                  S5      R	                  S5      05      n[        S[        R                  R                  S5      R	                  S5      05      n[        S[        R                  R                  S5      R	                  S5      05      n[        SS[
        4[        R                  R                  S5      R	                  S5      05      n[        U 5       nSnUR                  Xq5        X#XE4 HL  n[        R                  " S	5      n	[        R                  " [        U	S
9   UR                  Xx5        S S S 5        MN     S S S 5        g ! , (       d  f       Mh  = f! , (       d  f       g = f)Nr6   )rW   r5   r4   rW   r5   r6   )1r6   rk   df_diff_valerrorz?cannot match existing table structure for [0] on appending datar   )r   r"   r_   r`   ra   r&   r   r@   rA   rB   r)   r*   rc   )
r-   r   rD   df3df4df5r/   namedr0   s
             r1   7test_append_with_diff_col_name_types_raises_value_errorrr      sK   	299((+;;GD	EB
S"))//2BB2FG
HC
VRYY2215EEbIJ
KC
Xryy44Q7GGKL
MC
c1f%ryy'<'<Q'?'O'OPR'ST
UC	J	'5!TC%A))QC z5T% 65	 &	 
(	' 65 
(	's%   .A
F18F
F1
F.)F11
F?c                    [        [        R                  R                  S5      R                  S5      [	        S5      [	        S5      S9n[
        R                  " U 5       nSn[        R                  " [        US9   UR                  USS	S
9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr6   r   r8   abcdABCDEr   r   z)complib only supports \[.*\] compression.r   r   foolib)r]   complib)r   r"   r_   r`   r%   tmensure_cleanr)   r*   rc   re   )r-   r   rg   r0   s       r1   test_invalid_complibr|      s    	
		a ''/6lW
B
 
	$:]]:S1IIdhI7 2 
%	$11 
%	$s$    B0<BB0
B-	)B00
B>idx2019Dr7   UTC)rY   r;   tzabcc                     [         R                  " X /5      n[        SUS/S9nX-  n[        R                  " [
        SS9   UR                  USS9  S S S 5        g ! , (       d  f       g = f)Nr   r4   rw   zSaving a MultiIndexr   r   r]   )r   from_arraysr   r)   r*   NotImplementedErrorre   )r}   rf   r-   mir   rg   s         r1   &test_to_hdf_multiindex_extension_dtyper      s[     
		
	+B	1B	.B D	*2G	H
		$D	! 
I	H	Hs   A
A)c                     U " SSS5      nSn[         R                  " [        US9   [        U5        S S S 5        g ! , (       d  f       g = f)Niodataz"legacy_hdf/incompatible_dataset.h5z_Dataset\(s\) incompatible with Pandas data types, not table, or no datasets found in HDF5 file.r   )r)   r*   rc   r   )datapath	data_pathmessages      r1   test_unsuppored_hdf_file_errorr      s?    v'KLI	8 
 
z	1 
2	1	1s	   ;
A	c                    [        [        R                  R                  S5      R                  S5      [	        S5      [	        S5      S9nX-  nSn[
        R                  " [        US9   [        US5        S S S 5        UR                  US	S
9  [        USS9nUR                  5         Sn[
        R                  " [        US9   [        US	5        S S S 5        g ! , (       d  f       Ni= f! , (       d  f       g = f)Nr6   rt   ru   rv   rw   zFile [\S]* does not existr   r]   r   r   r)modez&The HDFStore must be open for reading.)r   r"   r_   r`   r%   r)   r*   OSErrorr   re   r   close)r-   rf   r   rg   r0   r/   s         r1   test_read_hdf_errorsr      s    	
		a ''/6lW
B  D
&C	wc	*u 
+ IIdIT$E	KKM
2C	wc	* 
+	* 
+	* 
+	*s   )CC*
C'*
C8c                      Sn [         R                  " [        U S9   [        [	        S5      S5        S S S 5        g ! , (       d  f       g = f)Nz5Support for generic buffers has not been implemented.r       r   )r)   r*   r   r   r   )r0   s    r1   #test_read_hdf_generic_buffer_errorsr      s0    
AC	*#	6t$ 
7	6	6s	   ;
A	bad_versionrj   )r5   12123c                     Sn[         R                  " [        US9   [        SU S9  S S S 5        g ! , (       d  f       g = f)Nz5Version is incorrect, expected sequence of 3 integersr   values_block_0)version)r)   r*   rc   r   )r   r0   s     r1   )test_maybe_adjust_name_bad_version_raisesr      s,    
AC	z	-+[A 
.	-	-s   0
>)&rP   r   r   rA   numpyr"   r)   pandasr   r   r   r   r   r	   rz   r
   r   pandas.tests.io.pytables.commonr   pandas.io.pytablesr   r   mark
single_cpu
pytestmarkr2   rE   rU   rh   rr   r|   parametrizer%   r   r   r   r   r    r   r1   <module>r      s      	  	 	 	 ?
 [[##
6.A"1J;2|&&	8 	6Q59e%""	*% r4(GHB IBr   