
    I j                        S SK r S SKJr  S SK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  S SKJrJr  \R&                  R(                  /rS rS rS rS rS	 rS
 rS rS rS r\R&                  R?                  S\" 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
date_rangeread_hdf)Term_maybe_adjust_namec                 (   [        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 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        g s  snf ! , (       d  f       NI= 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rangeputpytestraises	TypeErrorselecttemp_hdfstoreir   msgs       u/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/tests/io/pytables/test_errors.pytest_pass_spec_to_storerr0      s    	biin$$W--d6l&1uRy1y!r!Xy1@
B dB	=  
y	,TC51 
-	D  
y	,T+7 
-	, 2 
-	, 
-	,s   C-C2D2
D 
Dc           	      (   [        S/ SQ05      n[        S/ SQ0[        SSSS9S9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        g ! , (       d  f       g = f)Na)         )r         z1/1/2000r5   nsperiodsunit)r   frametableformatz3incompatible kind in col [integer - datetime64[ns]]r   T)r?   append)r   r	   r&   reescaper'   r(   r)   )r,   df1df2r.   s       r/   $test_table_index_incompatible_dtypesrE   1   s    
S)$
%C
	i
:qt LC gs73
))I
JC	y	,'3wtD 
-	,	,s   'B
Bc                    S[         R                  " SSS5      4/nU H  u  p#[        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X5U'   [        R                  " SU S35      n[        R                  " [        US9   U R                  SU 3U5        S S S 5        M     g s  snf ! , (       d  f       M  = f)Ndate  r3   r4   r   r   r   r   r   r   r   r   [z&] is not implemented as a table columnr   df1_)datetimerG   r   r    r!   r"   r   r#   r$   r%   rA   rB   r'   r(   r)   r@   )r,   dtypesnfr-   r   r.   s          r/   'test_unimplemented_dtypes_table_columnsrO   =   s    x}}T1a012F "))C.((11$v,f55959a2aS95VD

 1ii!A3DEF]]9C0  4sR0 10  6 10s   7C,	C11
D 	c                 V   [        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SR                  [        R                  " S5      [        R                  " S5      /5      n[        R                  " [         US9   U R#                  SU5        S S S 5        g s  snf ! , (       d  f       g = f)Nr   r   r   r   r   r   r   r   fooobj1barobj2rH   r3   r4   	datetime1|zjCannot serialize the column [datetime1]
because its data contents are not [string] but [date] object dtypez+[date] is not implemented as a table columnr   df_unimplemented)r   r    r!   r"   r   r#   r$   r%   rK   rG   _consolidatejoinrA   rB   r'   r(   r)   r@   r+   s       r/   (test_unimplemented_dtypes_table_columns2rZ   M   s    	biin$$W--d6l&1uRy1y!r!Xy1@
B
 BvJBvJmmD!Q/B{O		B ((IID IICD	
C 
y	,/4 
-	,# 2" 
-	,s   D9D
D(c                    [        [        R                  R                  S5      R	                  S5      [        [        S5      [        S9[        S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        g ! , (       d  f       N= f! , (       d  f       NV= f! , (       d  f       g = f)Nr4   
   r   r   r   z
2000-01-01r]   Br8   )r:   freqr;   r   rQ   stringrS   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>)r   r    randomdefault_rngstandard_normalr   r#   r$   r	   locr   r&   rA   rB   r'   r(   r)   r   
ValueErrorr*   SyntaxError)r,   r   r.   s      r/   test_invalid_termsrg   g   s-   	
		a 009d6l&1r$G
B
 BxL&+BFF288Aa=("#dBw/ ))P
QC	y	, 
- ))	9C 
z	-T=1 
. C	{#	.T8, 
/	. 
-	, 
.	- 
/	.s$   :E<E2E0
E
E-0
E>c           
          [        [        R                  R                  S5      R	                  S5      [        S5      [        S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  g )Nr4   r\   r   20130101r]   r8   r9   r   dfqr=   T)keyr?   data_columnsz0index>Timestamp('20130104') & columns=['A', 'B']r   
A>0 or C>0)	r   r    ra   rb   rc   r#   r	   to_hdfr
   )temp_h5_pathrj   s     r/   test_invalid_terms_from_docsrp      sr    

		a 009VRd;C
 JJ|wTJJ e#U \55    c           
      8   [        [        R                  R                  S5      R	                  S5      [        S5      [        S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 = f)Nr4   r\   r   ri   r]   r8   r9   r   rj   r=   )rk   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\nr   rm   r   )r   r    ra   rb   rc   r#   r	   rn   r'   r(   re   r
   )ro   rj   r.   s      r/   test_invalid_terms_referencers      s    

		a 009VRd;C
 JJ|wJ7	A  
z	-uL9 
.	-	-s   6B
B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SnU R                  Xa5        X#XE4 HL  n[        R                  " S	5      n[        R                  " [        US
9   U R                  Xg5        S S S 5        MN     g ! , (       d  f       M`  = f)Nr4   )r]   r3   r2   r]   r3   r4   )1r4   rv   df_diff_valerrorz?cannot match existing table structure for [0] on appending datar   )r   r    ra   rb   rc   r$   r@   rA   rB   r'   r(   re   )	r,   r   rD   df3df4df5namedr.   s	            r/   7test_append_with_diff_col_name_types_raises_value_errorr}      s4   	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D"!iiM
 ]]:S1  ) 21	 " 21s   ,F
F	c                 "   [        [        R                  R                  S5      R                  S5      [	        S5      [	        S5      S9nSn[
        R                  " [        US9   UR                  U SS	S
9  S S S 5        g ! , (       d  f       g = f)Nr4   r   r6   abcdABCDEr   r   z)complib only supports \[.*\] compression.r   r   foolib)rk   complib)	r   r    ra   rb   r#   r'   r(   re   rn   )ro   r   r.   s      r/   test_invalid_complibr      sj    	
		a ''/6lW
B
 7C	z	-
		,D(	; 
.	-	-s   %B  
Bidx2019Dr5   UTCr8   )r_   r:   tzr;   abcc                     [         R                  " X /5      n[        SUS/S9n[        R                  " [
        SS9   UR                  USS9  S S S 5        g ! , (       d  f       g = f)Nr   r2   r   zSaving a MultiIndexr   r   rk   )r   from_arraysr   r'   r(   NotImplementedErrorrn   )r   ro   mir   s       r/   &test_to_hdf_multiindex_extension_dtyper      sS     
		
	+B	1B	.B	*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(   re   r
   )datapath	data_pathmessages      r/   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Sn[
        R                  " [        US9   [        [        R                  " 5        S3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)Nr4   r   r   r   r   zFile [\S]* does not existr   z.h5rk   r   r   r)modez&The HDFStore must be open for reading.)r   r    ra   rb   r#   r'   r(   OSErrorr
   uuiduuid4rn   r   close)ro   r   r.   stores       r/   test_read_hdf_errorsr      s    	
		a ''/6lW
B 'C	wc	*DJJL>%u- 
+ IIlI%\,E	KKM
2C	wc	* 
+	* 
+	* 
+	*s   %#C+C<+
C9<
D
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   rq   r   )r'   r(   r   r
   r   )r.   s    r/   #test_read_hdf_generic_buffer_errorsr      s0    
AC	*#	6t$ 
7	6	6s	   ;
A	bad_versionru   )r3   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(   re   r   )r   r.   s     r/   )test_maybe_adjust_name_bad_version_raisesr      s,    
AC	z	-+[A 
.	-	-s   0
>)&rK   r   r   rA   r   numpyr    r'   pandasr   r   r   r   r   r	   r
   pandas.io.pytablesr   r   mark
single_cpu
pytestmarkr0   rE   rO   rZ   rg   rp   rs   r}   r   parametrizer#   r   r   r   r   r    rq   r/   <module>r      s      	     
 kk$$%
8,	E1 54-:6 :(*$< 	6Q5tDe%**	(% r4(GHB IBrq   