
    Eg               	          d dl Z d dlmZ d dlZd dl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 d dlmZmZ ej        j        Zd Zd Zd Zd	 Zd
 Zd Zej                            d edddd           e e d                    g          d             Z!d Z"d Z#d Z$ej                            dddg ddg          d             Z%dS )    N)BytesIO)CategoricalIndex	DataFrameHDFStoreIndex
MultiIndex_testing
date_rangeread_hdf)ensure_clean_store)Term_maybe_adjust_namec           
         t          dt          j        d                              d          z  t	          t          d          t                    t	          d t          d          D             t                              }t          |           5 }|	                    d	|           d
}t          j        t          |          5  |                    d	dg           d d d            n# 1 swxY w Y   d}t          j        t          |          5  |                    d	dg           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 )N皙?x         ABCDdtypec                     g | ]}d | S zi- .0is     Y/var/www/sysmax/venv/lib/python3.11/site-packages/pandas/tests/io/pytables/test_errors.py
<listcomp>z,test_pass_spec_to_storer.<locals>.<listcomp>        111!X!XX111    r   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_pathr%   storemsgs       r   test_pass_spec_to_storerr9      s   	binn$$W---d6ll&11111uRyy111@@@
 
 
B 
J	'	' 65		$A 	 ]9C000 	. 	.LLuL---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.H 	 ]9C000 	6 	6LL{_L555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6sZ   4E
C/#E/C3	3E6C3	7 ED<0E<E 	 EE 	EEEc                    t          dg di          }t          dg dit          dd                    }t          |           5 }|                    d|d	
           t	          j        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 )Na)         )r         z1/1/2000r>   periods)r$   frametableformatz3incompatible kind in col [integer - datetime64[ns]]r&   T)rF   append)	r   r
   r   r1   reescaper2   r3   r4   )r6   df1df2r7   r8   s        r   $test_table_index_incompatible_dtypesrL   3   s   
S)))$
%
%C
S)))$Jz1,M,M,M
N
N
NC	J	'	' A5		'3w	///iMNN]9C000 	A 	AIIgs74I@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	AA A A A A A A A A A A A A A A A A As7   ACB5)C5B9	9C<B9	=CCCc                    t          |           5 }dt          j        ddd          fg}|D ]\  }}t          dt	          j        d                              d          z  t          t          d          t          	          t          d
 t          d          D             t          	                    }|||<   t          j        d| 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          dt	          j        d                              d          z  t          t          d          t          	          t          d t          d          D             t          	                    }d|d<   d|d<   t          j        ddd          |d<   |                                }t          |           5 }t          j        d          }t          j        t          |          5  |                    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 )Ndatei  r<   r=   r   r   r   r   r   c                     g | ]}d | S r   r   r   s     r   r   z;test_unimplemented_dtypes_table_columns.<locals>.<listcomp>G   s    999!X!XX999r!   r   r"   [z&] is not implemented as a table columnr&   df1_c                     g | ]}d | S r   r   r   s     r   r   z;test_unimplemented_dtypes_table_columns.<locals>.<listcomp>R   r    r!   fooobj1barobj2	datetime1zjCannot serialize the column [datetime1]
because its data contents are not [string] but [date] object dtypedf_unimplemented)r   datetimerN   r   r+   r,   r-   r   r.   r/   r0   rH   rI   r2   r3   r4   rG   _consolidate)r6   r7   dtypesnfr%   r8   s          r   'test_unimplemented_dtypes_table_columnsr^   >   s_   	J	'	' -58=q!4456  		- 		-DAqbinn,,W555d6ll&99999uRyy999HHH  B
 BqE)IIIIJJCy444 - -ZAZZ,,,- - - - - - - - - - - - - - -		-	- - - - - - - - - - - - - - -  
binn$$W---d6ll&11111uRyy111@@@
 
 
B
 BvJBvJmD!Q//B{O			B	J	'	' 15iF
 
 ]9C000 	1 	1LL+R000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1sl   CD./D	D.DD.DD..D25D20I05II0I	I0I	 I00I47I4c           
      f   t          |          5 }t          t          j                            d                              d          t          t          d          t                    t          ddd          	          }d
|d<   d|j
        |j        dd         df<   |                    d|d           t          j        d          }t          j        t"          |          5  t%                       d d d            n# 1 swxY w Y   t          j        d          }t          j        t&          |          5  |                    dd           d d d            n# 1 swxY w Y   d}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   | |z  }t          t          j                            d                              d          t          d          t          dd          	          }|                    |ddd           t/          |dd           t/          |dd           | |z  }t          t          j                            d                              d          t          d          t          dd          	          }|                    |dd            d!}t          j        t&          |          5  t/          |dd           d d d            d S # 1 swxY w Y   d S )"Nr=   )
   r   r   r   z
2000-01-01r`   B)rB   freqr"   rS   stringrU   r   r   r%   rD   rE   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>20130101rA   dfqT)keyrF   data_columnsz0index>Timestamp('20130104') & columns=['A', 'B']r)   z
A>0 or C>0)rf   rF   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$   r1   rH   rI   r2   r3   r4   r   
ValueErrorr5   SyntaxErrorto_hdfr   )tmp_pathr6   r7   r%   r8   pathre   s          r   test_invalid_termsrq   c   sQ   	J	'	' )5I!!!$$44W==$v,,f555\2C@@@
 
 

 8*/rx!}h&'		$7	+++ iTUU]9C000 	 	FFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 i=
 
 ]:S111 	. 	.LL}---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. ];c222 	) 	)LLx(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)3) ) ) ) ) ) ) ) ) ) ) ) ) ) ): j D

	a  0099VR000  C
 JJtwTJBBB T5 RSSSST5---- j D

	a  0099VR000  C
 JJtwJ///	A  
z	-	-	- 2 2uL11112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2s   CG)D8GD	GD	2G>E!G!E%	%G(E%	) G	F, G,F0	0G3F0	4GG
GL&&L*-L*c                    t          t          j                            d                              d                    }t          dt          j                            d                              d          i          }t          dt          j                            d                              d          i          }t          dt          j                            d                              d          i          }t          ddt
          ft          j                            d                              d          i          }t          |           5 }d}|                    ||           ||||fD ]_}t          j	        d	          }	t          j        t          |	
          5  |                    ||           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<   r=   )1r=   rt   df_diff_valerrorz?cannot match existing table structure for [0] on appending datar&   )r   r+   rh   ri   rj   r/   r   rG   rH   rI   r2   r3   rl   )
r6   r%   rK   df3df4df5r7   namedr8   s
             r   7test_append_with_diff_col_name_types_raises_value_errorr{      s/   	29((++;;GDD	E	EB
S")//22BB2FFG
H
HC
VRY22155EEbIIJ
K
KC
Xry44Q77GGKKL
M
MC
c1f%ry'<'<Q'?'?'O'OPR'S'ST
U
UC	J	'	' 	&5!T2sC% 	& 	&A)Q C z555 & &T1%%%& & & & & & & & & & & & & & &		&		& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s7   AG(+GG(GG(GG((G,/G,c                    t          t          j                            d                              d          t	          d          t	          d                    }t          j        |           5 }d}t          j        t          |          5  |
                    |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   r?   abcdABCDEr$   r#   z)complib only supports \[.*\] compression.r&   r%   foolib)rf   complib)r   r+   rh   ri   r.   tmensure_cleanr2   r3   rl   rn   )r6   r%   rp   r8   s       r   test_invalid_complibr      sC   	
	a  ''//6llW
 
 
B
 
	$	$ 8:]:S111 	8 	8IIdhI777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	88 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8s6   1CB4(C4B8	8C;B8	<CCCidx2019Dr>   UTC)rb   rB   tzabcc                     t          j        | | g          }t          d|dg          }||z  }t          j        t
          d          5  |                    |d           d d d            d S # 1 swxY w Y   d S )Nr   r;   r   zSaving a MultiIndexr&   r%   rf   )r   from_arraysr   r2   r3   NotImplementedErrorrn   )r   ro   r6   mir%   rp   s         r   &test_to_hdf_multiindex_extension_dtyper      s     
	c
	+	+B	1B	.	.	.Bj D	*2G	H	H	H " "
		$D	!!!" " " " " " " " " " " " " " " " " "s   
A//A36A3c                      | ddd          }d}t          j        t          |          5  t          |           d d d            d S # 1 swxY w Y   d S )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&   )r2   r3   rl   r   )datapath	data_pathmessages      r   test_unsuppored_hdf_file_errorr      s    v'KLLI	8 
 
z	1	1	1                   s   AAAc                 V   t          t          j                            d                              d          t	          d          t	          d                    }|| z  }d}t          j        t          |          5  t          |d           d d d            n# 1 swxY w Y   |	                    |d	
           t          |d          }|                                 d}t          j        t          |          5  t          |d	           d d d            d S # 1 swxY w Y   d S )Nr=   r}   r~   r   r   zFile [\S]* does not existr&   rf   r%   r   r)modez&The HDFStore must be open for reading.)r   r+   rh   ri   r.   r2   r3   OSErrorr   rn   r   close)r6   ro   r%   rp   r8   r7   s         r   test_read_hdf_errorsr      s   	
	a  ''//6llW
 
 
B j D
&C	wc	*	*	*  u               IIdIT$$$E	KKMMM
2C	wc	*	*	*                   s$   ?BB #B  DD"%D"c                      d} t          j        t          |           5  t          t	          d          d           d d d            d S # 1 swxY w Y   d S )Nz5Support for generic buffers has not been implemented.r&   r!   r%   )r2   r3   r   r   r   )r8   s    r   #test_read_hdf_generic_buffer_errorsr      s    
AC	*#	6	6	6 % %t$$$% % % % % % % % % % % % % % % % % %s   A		AAbad_versionrs   )r<   12123c                     d}t          j        t          |          5  t          d|            d d d            d S # 1 swxY w Y   d S )Nz5Version is incorrect, expected sequence of 3 integersr&   values_block_0)version)r2   r3   rl   r   )r   r8   s     r   )test_maybe_adjust_name_bad_version_raisesr      s    
AC	z	-	-	- 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   =AA)&rY   r   r   rH   numpyr+   r2   pandasr   r   r   r   r   r	   r   r
   r   pandas.tests.io.pytables.commonr   pandas.io.pytablesr   r   mark
single_cpu
pytestmarkr9   rL   r^   rq   r{   r   parametrizer.   r   r   r   r   r   r   r!   r   <module>r      s#          				     	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ? > > > > >       
 [#
6 6 6.A A A"1 "1 "1J;2 ;2 ;2|& & &&	8 	8 	8 	
6Q5999e%% " " "	 	 	  *% % % r4(GHHB B IHB B Br!   