
    {och                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl	m
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mZmZ d dlmZ d dlmZmZ d dlm Z m!Z! ejD                  jF                  gZ$ ejJ                  d      Z&d Z'd	 Z(d
 Z)d Z*d Z+d Z,ejD                  j[                  ddddh e.       f e.       ddhfdhddhf e.       dhfdfddhddhf e.       dhfdfg      d        Z/d Z0d Z1d Z2d Z3ejD                  ji                   e
       xr ed !      ejD                  j[                  d"d#d$g      d%               Z5d& Z6d' Z7d( Z8d) Z9d* Z:d+ Z;d, Z<d- Z=ejD                  j[                  d.dd/g      ejD                  j[                  d0d$d#g      d1               Z>d2 Z?d3 Z@d4 ZAd5 ZBd6 ZCd7 ZDd8 ZEd9 ZFejD                  j[                  d:g d;      d<        ZGd= ZHd> ZId? ZJejD                  j[                  d@dAdBg      dC        ZKdD ZLdE ZMdF ZNejD                  j                  dG      ejD                  j[                  dH ed dIgej                  J       edKdLgej                  J       edMdNO       edPdNO       edMdNdQR      g      dS               ZRejD                  j[                  dTddUg      dV        ZSdW ZTdX ZUy)Y    N)using_string_dtype)HAS_PYARROW)
	DataFrameDatetimeIndexIndex
MultiIndexSeries	Timestampconcat
date_rangeperiod_rangetimedelta_range)_maybe_removeensure_clean_storeHDFStoreread_hdftablesc                    t        j                  |       5 }	 t        |      5 }t        d      # 1 sw Y   nxY wn# t        $ r Y nw xY wd d d        n# 1 sw Y   nxY wt        j                  |       5 }t        |      5 }t	        dt        j                  d      j                  d      z  t        t        d      t              t        t        d      D cg c]  }d| 	 nc c}w c}t              	      |d
<   t        |      dk(  sJ t        |d
         t        k(  sJ 	 d d d        n# 1 sw Y   nxY wd d d        y # 1 sw Y   y xY w)Nblah皙?x         ABCDdtyper   i-columnsindexa   )tmensure_cleanr   
ValueErrorr   nparangereshaper   listobjectrangelentype)
setup_pathpathtblis       r/mnt/ACDE16A4DE16673C/PROJECTS/MIS_PORTAL/venv/lib/python3.12/site-packages/pandas/tests/io/pytables/test_store.pytest_contextr5   +   s)   		$ 	$ )3 (() ) ) 			   
	$ /d^ 	/s biin,,W55d6l&9uRy9!r!X99HCH
 s8q= =C>Y...	/ 	/ 	// / /si   A</8	<A	AAAAA5EAD0C%$AD0'	E0D9	5EEc                     t         j                  dfdfd} || d      } || d      }t        j                  d        || d      } || d      }||k(  sJ ||k7  sJ y )N   c                      |       t        | d      5 t        fdd      D ]  }j                  |        	 d d d        j                         S # 1 sw Y   j                         S xY w)Nrbc                  @    j                   j                  z        S N)read
block_size)chunk_num_blocksfhs   r4   <lambda>z7test_no_track_times.<locals>.checksum.<locals>.<lambda>D   s    aff-=-L&M     rB   )openiterupdatedigest)filenamehash_factoryr>   chunkr?   r@   s     ` @@r4   checksumz%test_no_track_times.<locals>.checksumA   sd    N(D! 	 QMsS   	  xxz	  xxzs   (AA0c           	          | z  }t        ddgi      }t        |d      5 }|j                  d|ddd |       d d d         |      S # 1 sw Y   xY w)Nr#   r$   wmodetableT)formatdata_columnsr"   track_times)r   r   put)tmp_pathrR   r1   dfhdfrJ   r0   s        r4   create_h5_and_return_checksumz:test_no_track_times.<locals>.create_h5_and_return_checksumH   sm    *$aSz"d% 	GG!'  	 ~	 	s   A

AF)rR   Tr$   )hashlibmd5timesleep)rT   r0   rW   checksum_0_tt_falsechecksum_0_tt_truechecksum_1_tt_falsechecksum_1_tt_truerJ   s    `     @r4   test_no_track_timesr`   =   s}     )0c   8eT6xTR 	JJqM7eT6xTR "5555 !3333rB   c                 f    t        |       5 }t        |      g k(  sJ 	 d d d        y # 1 sw Y   y xY wr;   )r   r+   )r0   stores     r4   test_iter_emptyrc   h   s3    	J	' !5E{b   ! ! !s   '0c                    t        |       5 }t        |       |j                          t        t	        j
                  dt        j                        t        dd            |d<   t        t        d      dt        d      D cg c]  }d| 	 c}	      |d
<   t        dt	        j
                  d      j                  d      z  t        t        d      t              t        t        d      D cg c]  }d| 	 c}t                    |d<   t        dt	        j
                  d      j                  d      z  t        t        d      t              t        t        d      D cg c]  }d| 	 c}t                    }d|d<   d|d<   |d   dkD  |d<   |d   dkD  |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<   |j)                         }|rd nt*        j,                  j.                  }d+}t1        j2                  ||,      5  ||d-<   d d d        |j4                  j7                  |j4                  j8                  d.       |j:                  t        |      v sJ |j:                  t=        |      v sJ |j                          d d d        t        |       5 }t        dt	        j
                  d      j                  d      z  t        t        d      t              t        t        d      D cg c]  }d| 	 c}t                    }|j?                  d-|       |jA                  d-      }t        |       t=        |       d d d        y c c}w c c}w c c}w # 1 sw Y   UxY w# 1 sw Y   xY wc c}w # 1 sw Y   y xY w)/N
   r   
2020-01-01periodsr"   r#   float64i_)r   r"   br   r   r   r   r   r   r    cfooobj1barobj2Ar   bool1Bbool2Tbool3r$   int1   int220010102
timestamp120010103
timestamp2i  	datetime1   	datetime2   z0cannot
map directly to c-types .* dtype='object'matchrU   bah)!r   reprinfor	   r(   r)   rj   r   r-   r   r*   r   r+   r,   r
   dtdatetimenanlocr"   _consolidatepderrorsPerformanceWarningr%   assert_produces_warning_handlecreate_grouprootrG   strappend
get_storer)r0   using_infer_stringrb   r3   rU   warningmsgss           r4   	test_reprr   n   sc   	J	' ,5U

IIb

+:lTV3W
c
 "IYr.KAA3x.K
c
 "))C.((11$v,f5595a2aS5VD
c
 "))C.((11$v,f5595a2aS5VD

 6
6
gk7gk776
6
$Z0<$Z0<++dAq!Q7;++dAq!Q7;*,&&rxx!}vh&'__,$"))2N2NA''s; 	E$K	 	""5==#5#5u=~~e,,,~~U+++

Y,^ 
J	' 
5"))C.((11$v,f5595a2aS5VD

 	T2T"QA
 
Q /L
 6 6$	 	I, ,f 6	
 
sr   A7O"OA!O"0O<A+O"'O3D	O"<OA:O"AO3&O.2AO3O"O	O""O+.O33O<c                 ~   t        |       5 }t        t        j                  dt        j                        t        dd            |d<   t        dt        j                  d      j                  d	      z  t        t        d
      t              t        t        d      D cg c]  }d| 	 c}t                    |d<   t        dt        j                  d      j                  d	      z  t        t        d
      t              t        t        d      D cg c]  }d| 	 c}t                    |d<   d|v sJ d|v sJ d|vsJ d|v sJ d|v sJ d|vsJ d|vsJ t        j                  t        j                  d      5  t        dt        j                  d      j                  d	      z  t        t        d
      t              t        t        d      D cg c]  }d| 	 c}t                    |d<   d d d        d|v sJ 	 d d d        y c c}w c c}w c c}w # 1 sw Y   (xY w# 1 sw Y   y xY w)Nre   r   rf   rg   ri   r#   r   r   r   r   r   r   r    rl   zfoo/barrm   z/foo/barz/foo/brp   F)check_stacklevelznode()))r   r	   r(   r)   rj   r   r   r*   r   r+   r,   r-   r%   r   r   NaturalNameWarning)r0   rb   r3   s      r4   test_containsr      s	   	J	' "5IIb

+:lTV3W
c
 "))C.((11$v,f5595a2aS5VD
c

 %"))C.((11$v,f5595a2aS5VD
i
 e||e||%E!!!U"""u$$$E!!! ''%%
 	  )biin,,W55d6l&9uRy9!r!X9H E)	 E!!!?" " 6
 6" :	 	/" "sW   BH3!H-A+H3H$A$H3AH'H"+H' H3
H3"H''H0	,H33H<c                    t        |       5 }t        t        j                  dt        j                        t        dd            |d<   t        dt        j                  d      j                  d	      z  t        t        d
      t              t        t        d      D cg c]  }d| 	 c}t                    |d<   t        t        j                  j                  d      j                  d      t        t        d
      t              t        ddd            }t        |d       |j!                  d|d d        |j!                  d|dd         |j"                  j$                  j&                  j(                  dk(  sJ |j"                  j*                  j&                  j(                  dk(  sJ |j"                  j,                  j&                  j(                  dk(  sJ t        |d       |j!                  d|       d |j/                  d      j&                  _        d}t1        j2                  t4        |      5  |j7                  d       d d d        d d d        y c c}w # 1 sw Y   xY w# 1 sw Y   y xY w)Nre   r   rf   rg   ri   r#   r   r   r   r   r   r   r    rl   rx   )   r   
2000-01-01r   rt   rh   freqdf1z0.15.2df2z/'NoneType' object has no attribute 'startswith'r   )r   r	   r(   r)   rj   r   r   r*   r   r+   r,   r-   randomdefault_rngstandard_normalr   r   r   r#   _v_attrspandas_versionrl   r   get_nodepytestraises	Exceptionselect)r0   rb   r3   rU   r   s        r4   test_versioningr      s   	J	'   5IIb

+:lTV3W
c
 "))C.((11$v,f5595a2aS5VD
c

 II!!!$44W=$v,f5\2C@

 	eU#UBsG$UBrsG$zz||$$33x???zz||$$33x???zz~~&&55AAA 	eU#UB 9=u&&5?]]9C0 	 LL	 ?      60	  	 ?     s7   BI2!I!-FI2>I&I2!I2&I/	+I22I;zwhere, expected/first_groupsecond_groupr   r   third_groupdf3s1df4) /first_group/second_group/second_group/third_groupr   )r   r   c                    t        g d      t        g d      t        g d      t        g d      t        g d      t        j                  g dg dg      t        j                  ddgd      t        j                  dd	gd      d
}t	        dd      5 }|j                  d|d          |j                  d|d          |j                  d|d          |j                  d|d          |j                  d|d          |j                  j                  dd|d          |j                  j                  dd|d          |j                  j                  dd|d          t        t        |j                  |                   t        |      k(  sJ |j                  |       D ]  \  }}}||v sJ ||   \  }}|t        |      k(  sJ |t        |      k(  sJ |D ]]  }	dj                  ||	g      }
|j                  |
      }d |	v rt        j                   |||	          Et        j"                  |||	          _  	 d d d        y # 1 sw Y   y xY w)!N)r$   rx   r   )r      r   )r         )	   re      )re   r   r   zi,i,ir   )r   r   r   )re   r      )r   r   r   r   r   a1tb1tb2zwalk_groups.hdfrL   rM   z/first_group/df1r   z/first_group/df2r   z/second_group/df3r   z/second_group/s1r   z/second_group/third_group/df4r   r   r   r   )objr   r   wherer   rU   )r   r	   r(   arrayr   rS   r   create_arraycreate_tabler.   r+   walksetjoingetr%   assert_frame_equalassert_series_equal)r   expectedobjsrb   r1   groupsleavesexpected_groupsexpected_framesleaf
frame_pathr   s               r4   	test_walkr      s'   0 ###%Z hh	9-.xxI.g>xxL1A
D 
-C	8 <E		$d5k2		$d5k2		%tE{3		$d4j1		14;?"">4dD"">5d5k"J""?EtE{"K4


/01S]BBB$)JJUJ$; 	< D&&8###/7~,O_"c&k111"c&k111 < XXtTl3
ii
+4<))#tDz:**3T
;<	<< < <s   F)I

Ic           
      
   t        |       5 }t        t        j                  dt        j                        t        dd            }||d<   |j                  }t        j                  ||       t        |d      }t        j                  ||       t        t        j                  j                  d      j                  d      t        t        d	            t        d
dd            }||d<   |j                   }t        j"                  ||       dD ]8  }d| d}t%        j&                  t(        |      5  t        ||       d d d        : dD ]  }t        |d|         	 d d d        y # 1 sw Y   dxY w# 1 sw Y   y xY w)Nre   r   rf   rg   ri   r#   rx   re   r   r   r   rt   r   r    rU   )drN   r1   handlecomplibz$'HDFStore' object has no attribute ''r   )rN   r1   r   r   _)r   r	   r(   r)   rj   r   r#   r%   r   getattrr   r   r   r   r   r+   rU   r   r   r   AttributeError)r0   rb   r   resultrU   xr   s          r4   test_getattrr   /  sc   	J	' $5IIb

+:lTV3W
 c
 
vq)$
vq)II!!!$44W=$v,'\2C@

 d
fb) < 	"A81=C~S9 "q!" "	" 7 	$AEQqc7#	$9$ $0" "1$ $s$   D*E96E- E9-E62E99Fc                 R   t        dt        j                  dgdt        j                  t        j                  gdt        d            }t        ddgdt        j                  gdt        d            }| |z  }|j	                  |dd	
       t        |d      }t        j                  ||       | |z  }|j	                  |dd	d       t        |d      }t        j                  ||       | |z  }|j	                  |dd	d       t        |d      }t        j                  ||       y )N               @      ?)col1col2abcri   acrU   rO   keyrP   F)r   rP   dropnaT)r   r(   r   r+   to_hdfr   r%   r   )rT   r0   df_with_missingdf_without_missingr1   reloadeds         r4   test_store_dropnar   P  s   rvvs#c266266-BC5kO #sc266]34: j D4T':d#H/84j D4T'%Hd#H/84j D4T'$Gd#H,h7rB   c                     | |z  }d}t        ddddddddg      }t        j                  t        |      5  |j	                  |d       d d d        y # 1 sw Y   y xY w)NztStarting with pandas version 3.0 all arguments of to_hdf except for the argument 'path_or_buf' will be keyword-only.r$   rx   r   )rr   rt   Cr   r   )r   r%   r   FutureWarningr   )rT   r0   r1   r   rU   s        r4   test_keyword_deprecationr   k  sh    j D	7  
!!!,AAA.FG	HB		#	#M	= 
		$  s   AAc           	      n   | |z  }t        g dg dt        g d      t        dd      d      j                  d      }|j	                  |d	d
ddi       |j                         j                         j                  d      j                  d      }|j	                  |d	dd
       t        j                  t        |d	      t        ||g             |d   j	                  |dd
ddi       |d   j	                  |ddd
       t        j                  t        |d      t        |d   |d   g             y )N)r   r   r   g      @g      @)r   r   r   r   r   )foo1foo2foo3foo4foo520130101r   rg   )rr   rt   r   Dr   ss3rO   r"   r   )r   rP   min_itemsizelonger)r   T)r   r   rP   rt   ss4)r   r   r   	set_indexr   copyreset_indexassignr%   r   r   r   r   )rT   r0   r1   rU   r   s        r4   test_to_hdf_with_min_itemsizer  y  s   j D 
**?@J2		

 in  IIdgWaLII
'')


!
(
(8
(
4
>
>s
CCJJttGJ<(4/S	1BC sGNN4U7'1NNHOODeDOA8D%0&"S'3s89L2MNrB   u>   TODO(infer_string): can't encode '': surrogates not allowed)reasonrP   fixedrO   c                     dg}t        |t        |            }| |z  }|j                  |d|d       t        |dd      }t	        j
                  ||       y )Nu   foori   rO   surrogatepass)r   rP   r   )r   )r	   r   r   r   r%   r   )rT   rP   r0   dataserr1   r   s          r4   test_to_hdf_errorsr    sW     =D
U4[
)Cj DJJtJHdGO<F63'rB   c           
      F   t        |       5 fd}t        t        j                  j	                  d      j                  d      t        t        d            t        ddd      	      }d
|d<   d|d<   j                  d|ddg        |dd      j                  du sJ  |dd      j                  du sJ  |dd      j                  du sJ j                  d|dgddg        |dd      j                  du sJ  |dd      j                  du sJ  |dd      j                  du sJ t        d       j                  d|       d}t        j                  t        |      5  j!                  d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nc                 b    t        j                  |       j                  j                  |      S r;   r   r   rO   colstcolumnrb   s     r4   colz$test_create_table_index.<locals>.col  '    5++A.44996BBrB   rx   r   r   r   re   rt   r   r    rn   stringrp   string2r?   rQ   r"   Tf2)r"   rQ   Fz1cannot create table index on a Fixed format storer   )r   r   r(   r   r   r   r   r+   r   r   
is_indexedr   rS   r   r   	TypeErrorcreate_table_indexr0   r  rU   r   rb   s       @r4   test_create_table_indexr$    s   	J	' +5	C II!!!$44W=$v,'\2C@

 89S"Hi+@A3 ++t3333!,,4443	"--555 	T2hZx>ST4!,,5554"--5554#..%777 	eT"		$A]]9C0 	+$$T*	+9+ +8	+ 	+9+ +s$   EF(F:FF	FF c           
         t        |       5 fd}t        t        j                  j	                  d      j                  d      t        t        d            t        ddd      	      }d
|d<   d|d<   j                  d|dg        |dd      j                  du sJ  |dd      j                  du sJ d}t        j                  t        |      5   |dd      j                   d d d        d}t        j                  t        |      5  j                  ddg       d d d        d d d        y # 1 sw Y   LxY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nc                 b    t        j                  |       j                  j                  |      S r;   r  r  s     r4   r  z:test_create_table_index_data_columns_argument.<locals>.col  r  rB   rx   r   r   r   re   rt   r   r    rn   r  rp   r  r?   r  r"   Tz('Cols' object has no attribute 'string2'r   zcolumn string2 is not a data_column.
In order to read column string2 you must reload the dataframe 
into HDFStore and include string2 with the data_columns argument.r!   )r   r   r(   r   r   r   r   r+   r   r   r   r   r   r   r"  r#  s       @r4   -test_create_table_index_data_columns_argumentr(    sK    
J	' ?5	C II!!!$44W=$v,'\2C@

 89S"H:63 ++t3333!,,4448]]>5 	+Y**	+
P 	
 ]]>5 	?$$S9+$>	?7? ?$	+ 	+	? 	?7? ?s<   CED4)%EE #E4D=	9E E		EEc                 f   t        j                  t        dd      t        d      gddg      }t	        dg di|	      }t        |       5 }|j                  d
|d       |j                  d
d      }|j                  dgd d f   }t        j                  ||       d d d        y # 1 sw Y   y xY w)Nr   r   rg   dateid)namesr#   )r   g333333?g?gffffff?g      ?ri   rU   Tr  zid == 1r   r$   )r   from_arraysr   r-   r   r   r   r   ilocr%   r   )r0   idxrU   rb   actualr   s         r4   test_mi_data_columnsr1    s    

 
 	L!	,eAh7~C 
C233	?B	J	' 05T2D1d)477A36?
fh/0 0 0s   AB''B0c                 L   t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D cg c]  }d| 	 c}            }d|d	<   d
|d<   |d   dkD  |d<   |d   dkD  |d<   d|d<   d|d<   d|d<   t        d      j                  d      |d<   t        d      j                  d      |d<   t        d      j                  d      |d<   t        d      j                  d      |d<   t        j                  |j                  |j                  dd d	gf<   |j                         }t        |       5 }|j                  d |       t        j                   |j#                  d       |       d d d        y c c}w # 1 sw Y   y xY w)!Nr   r   r   r   r   r   r    rn   ro   rp   rq   rr   r   rs   rt   ru   Trv   r$   rw   rx   ry   rz   nsr{   r|   r}   r~   r   r   r   	df1_mixed)r   r(   r)   r*   r   r+   r-   r
   as_unitr   r   r"   r   r   r   r%   r   r   )r0   r3   rU   rb   s       r4   test_table_mixed_dtypesr6    s   	biin$$W--d6l#uRy1!r!X12
B
 BvJBvJS'A+BwKS'A+BwKBwKBvJBvJ ,44T:B| ,44T:B|
+33D9B{O
+33D9B{O&(ffBFF288Aa=6("#		B	J	' =5["%
ell;7<= =! 2 = =s   F8FF#c                    d}dt        j                  ddd      t        j                  d      g}t        j
                  j                  ||      }t        j                  ddd	      }t        |d|
      }t        |j                  |      j                  t        dj                                     }t        |       5 }|j                  d|       |j                  d      }t        j                   ||       |j#                  d|       |j                  d      }t        j                   ||       d d d        y # 1 sw Y   y xY w)NzSun Mon Tue Wed Thuz
2012-05-01i  r   r$   z
2014-05-01)holidaysweekmaskr   r   r   zMon Tue Wed Thu Fri Sat Sunr  rO   )r   r   r(   
datetime64r   offsetsCustomBusinessDayr   r	   weekdaymapsplitr   rS   r   r%   r   r   )	r0   weekmask_egyptr8  
bday_egyptmydtdtsr   rb   r   s	            r4   test_calendar_roundtrip_issuerD    s    +N
D!Q
l#H
 --N . J ;;tQ#D
T1:
6Cs{{C $$V,I,O,O,Q%RSA	J	' *5		'1g&
vq)Wa g&
vq)* * *s   =A3D99Ec                    t        |       5 }t        t        j                  dt        j                        t        dd            }t        dt        j                  d      j                  d      z  t        t        d	            t        t        d
      D cg c]  }d| 	 c}            }||d<   ||d<   t        |d       t        |      dk(  sJ t        j                  ||d          t        |d       t        |      dk(  sJ t        j                   t"        d      5  |j%                  d       d d d        ||d<   ||d<   t        |d       t        |d       t        |      dk(  sJ ||d<   ||d<   t        |d       t        |      dk(  sJ ||d<   ||d<   |d= |d= t        |      dk(  sJ 	 d d d        y c c}w # 1 sw Y   xY w# 1 sw Y   y xY w)Nre   r   rf   rg   ri   r   r   r   r   r   r   r    r#   rl   r$   r   z1'No object named a_nonexistent_store in the file'r   a_nonexistent_storezb/foorn   )r   r	   r(   r)   rj   r   r   r*   r   r+   r-   r   r.   r%   r   r   r   KeyErrorremove)r0   rb   tsr3   rU   s        r4   test_removerJ  (  s   	J	' )5IIb

+:lTV3W
 "))C.((11$v,'595a2aS56

 c
c
eS!5zQ
b%*-eS!5zQ ]]O
 	0 LL./	0 c
geU#eW%5zQc
geS!5zQ c
c
#J#J5zQS) ) 6	0 	0') )s8   BGG$BG&G8B GGG	GGc                    t        |       5 }t        t        j                  j	                  d      j                  d      t        dd            }|j                  d|d	       ||j                  t        d
      kD     }|j                  dd      }t        j                  ||       |j                  dd      }t        j                  ||       |j                  dd      }t        j                  ||       d d d        y # 1 sw Y   y xY w)Nrx   )r   rx   r  r   rg   ri   rU   rO   rP   20130105z!index>datetime.datetime(2013,1,5)zindex>datetime(2013,1,5))r   r   r(   r   r   r   r   rS   r"   r
   r   r%   r   )r0   rb   rU   r   r   s        r4   test_same_name_scopingrN  U  s    	J	' 05II!!!$44W=Z4
 			$7	+bhh:!667d$GH
fh/ d$GH
fh/d$>?
fh/'0 0 0s   C,DD
c                    t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D cg c]  }d| 	 c}            }d|j                  _        t        |       5 }||d	<   |d	   }t        j                  ||       d d d        y c c}w # 1 sw Y   y xY w)
Nr   r   r   r   r   r   r    rn   frame)r   r(   r)   r*   r   r+   r-   r"   namer   r%   r   )r0   r3   rU   rb   reconss        r4   test_store_index_namerS  l  s    	biin$$W--d6l#uRy1!r!X12
B
 BHHM	J	' *5gw
fb)* *	 2* *s   B/!B44B=tzz
US/Pacifictable_formatc                    t        t        j                  ddd      t        j                  ddd      gd      j                  |      }t        t        j                  ddd      t        j                  ddd      gd      j	                  |      j                  |      }t        t        j                  d      j                  dd      ||	      }| |z  }|j                  |d
|       t        |d
      }	t        j                  ||	d       t        |	j                  j                  t               sJ t        |	j"                  j                  t               sJ y )Ni  r$   rx   u   colsג)rQ  i  u   rowsאr   r    rU   r   T)check_names)r   r   r*  tz_localizer5  r   r(   r)   r*   r   r   r%   r   
isinstancer"   rQ  r   r!   )
rT   rU  r0   unitrT  r/  idx1rU   r1   r   s
             r4   test_store_index_name_numpy_strr\  z  s    	q!	bggdAq12 k"o 
 	WWT1a "''$1"56	
 
	R 	 
299Q<''1-s$	GB j DIId\I2
4
C"ct4ciinnc***ckk&&,,,rB   c                 h   t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D cg c]  }d| 	 c}            }|d   }t        |       5 }||d	<   |d	   }t        j                  ||       d d d        y c c}w # 1 sw Y   y xY w)
Nr   r   r   r   r   r   r    rr   series)
r   r(   r)   r*   r   r+   r-   r   r%   r   )r0   r3   rU   r^  rb   rR  s         r4   test_store_series_namer_    s    	biin$$W--d6l#uRy1!r!X12
B
 WF	J	' /5 hx
vv./ /	 2/ /s   B#9!B((B1c           
         t        |       5 }t        t        j                  j	                  d      j                  d      t        t        d            t        ddd            |d	<   t        t        j                  dt        j                  
      t        dd            }||d	<   t        j                  |d	   |       d d d        y # 1 sw Y   y xY w)Nrx   r   r   r   re   rt   r   r    r#   r   rf   rg   ri   )r   r   r(   r   r   r   r   r+   r   r	   r)   rj   r%   r   )r0   rb   rI  s      r4   test_overwrite_nodera    s    	J	' /5II!!!$44W=$v,'\2C@
c

 IIb

+:lTV3W
 c

uSz2./ / /s   B5C

Cc           
         t        t        j                  j                  d      j	                  d      t        t        d            t        ddd            }t        |       5 }t        |d	       |j                  d	|       |j                  d	      }|j                  t        j                  t        |j                              k(  j!                         sJ t        |d	       t        t#        d
      t#        d
      d      }|j                  d	|       |j                  d	dg      }|j                  t        j                  d      k(  j!                         sJ |j%                  d	|      }|j&                  ddd d f   }t)        j*                  ||       |j                  d	ddg      }|j                  t        j                  d      dz   k(  j!                         sJ |j%                  d	|      }|j&                  ddd d f   }t)        j*                  ||       t-        |t
              sJ t        |d       t        |d       t        t        j                  j                  d      j	                  d      t        t        d            t        ddd            }|j/                         j1                  dj2                        }|j                  d|ddg       |j                  d|       |j                  dddg      }|j%                  d|      }|j%                  d|      }	t5        ||	gd      }t5        ||gd      }||j6                  dkD  |j8                  dkD  z     }t)        j*                  ||d       d d d        t        |       5 }t        t        j                  j                  d      j	                  d      t        d d!"      #      }|j                  d	|       |j;                  d	d$      }|t=        |      j>                  d
k(     j                  }
|j@                  |
   }|j%                  d	|
      }t)        j*                  ||       |j%                  d	|
      }t)        j*                  ||       d%}tC        jD                  tF        |&      5  |j%                  d	t        j                  t        |      d'(             d d d        tC        jD                  tF        |&      5  |j%                  d	t        j                  t        |      dz                d d d        tC        jD                  tF        |&      5  |j%                  d	t        j                  t        |            d
)       d d d        tC        jD                  tF        |&      5  |j%                  d	t        j                  t        |            d
d*       d d d        t        d d+"      }|j%                  d	d,      }||j                  jI                  |         }t)        j*                  ||       t        t        j                  j                  d      j	                  d-            }|j                  d|       |j%                  dg d.      }|j@                  g d.   }t)        j*                  ||       d/gdz  }
d|
d0<   |j%                  d|
      }|j&                  |
   }t)        j*                  ||       |j%                  dd
d1      }|d
d }t)        j*                  ||       d d d        y # 1 sw Y   xY w# 1 sw Y   jxY w# 1 sw Y   !xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)2Nrx   r   r   r   re   rt   r   r    rU   r   rr   rt   zindex<3r   r   r   zindex>=3zindex<=4r   r   r   z{}_2r'  rr   r  zA>0zB>0r$   )axisF)
check_freq)  rx   20000101rf  rg   ri   r"   zLwhere must be passed as a string, PyTablesExpr, or list-like of PyTablesExprr   rj   r   )r   start)r   rh  stopi  zindex in selectionre   rx   )r   r   r   Trh  ri  )%r   r(   r   r   r   r   r+   r   r   r   r   select_as_coordinatesvaluesr)   r.   r"   allr-   r   r   r%   r   rY  r  renamerP   r   rr   rt   select_columnr   monthr.  r   r   r!  isin)r0   rU   rb   rm   r   r   r   r   
df1_result
df2_resultr   r   	selections                r4   test_coordinatesrw    sA   	
		a 009d6l#r<
B 
J	' -B5eT"T2 ''-BIIc"((m4499;;; 	eT"U1XE!H56T2''yk:BIIaL(--///d!,66!A#q&>
fh/''z:.FGBIIaL1,,11333d!,66!A#q&>
fh/!U### 	eU#eU#II!!!$44W=$v,'\2C@

 hhj6UCsCj9UC ''u~>\\%+
\\%+
Z0q93*1-XZZ!^

Q?@
fh5A[-Bd 
J	' :05II!!!$44Y?Z6
 	T2g.-"((A-.44775> d%0
fh/ d%0
fh/+ 	 ]]9C0 	JLLRYYs2wi%HLI	J ]]9C0 	=LLRYYs2w{%;L<	= ]]9C0 	BLLRYYs2w%7qLA	B ]]9C0 	KLLRYYs2w%7qrLJ	K z37	d*>?bhhmmI./
fh/ ryy,,Q/??HIUBe95779%
fh/ b	e5166%=
fh/ e126a8
fh/u:0 :0e-B -BR	J 	J	= 	=	B 	B	K 	KA:0 :0s{   $L!\1D]2$2\>#]293],#]21] #]2#2]%E]21\;>]	]2]	]2]"	]2%]/	*]22];c                 P   t        |       5 }t        t        j                  j	                  d      j                  d      t        j                  j	                  d      j                  d      d      }|j                  d|       |j                  dddd      }|j                  dd	d
gf   }t        j                  ||       |j                  dddd      }t        |      dk(  sJ |j                  ddd
gf   }t        j                  ||       d d d        y # 1 sw Y   y xY w)Nrx   r   rc  rU   zcolumns=['A']r   r   rl  r   rr   r   (   )r   r   r(   r   r   r   r   r   r%   r   r.   r0   rb   rU   r   r   s        r4   test_start_stop_tabler{  *  s
   	J	' 05YY**1-44R8YY**1-44R8
 	T2dO11E66!A#u*%
fh/ dO2BG6{a66"R%#,'
fh/%0 0 0s   DDD%c                    t        |       5 }t        ddgddgd      }|j                  dgd d|d       |j                  ddgdd	d
      }|j                  d	gddgf   }t        j                  ||       d d d        y # 1 sw Y   y xY w)Nr$   rx   )rn   rp   rn   )selectorr  r}  )r}  r  r   )r}  rh  ri  rp   )r   r   append_to_multipleselect_as_multipler   r%   r   rz  s        r4   test_start_stop_multipler  @  s    	J	' 
051vq!f56  $/j 	! 	
 )) :QQ * 
 661#u~-.
fh/
0 
0 
0s   A,BB
c                 J   t        |       5 }t        t        j                  j	                  d      j                  d      t        j                  j	                  d      j                  d      dt        dd            }|j                  d|       |j                  ddd	
      }|j                  dd	d d f   }t        j                  ||       |j                  dd	d
      }|j                  d	dd d f   }t        j                  ||       |j                  ddd
      }|j                  ddd d f   }t        j                  ||       |j                  }|j                  d|       |j                  ddd	
      }|j                  dd	 }t        j                  ||       |j                  dd	d
      }|j                  d	d }t        j                  ||       t        dt        j                  d      j                  d      z  t        t!        d            t        t#        d      D cg c]  }d| 	 c}            }t        j$                  |j                  dd	ddf<   t        j$                  |j                  dddf<   d d d        y c c}w # 1 sw Y   y xY w)Nrx   r   rc  r  rg   ri   rU   r   r   rl  re   r   ry  r   r   r   r   r   r   r    r   r$   r   rk  )r   r   r(   r   r   r   rS   r   r.  r%   r   rr   r   r)   r*   r   r+   r-   r   )r0   rb   rU   r   r   r   r3   s          r4   test_start_stop_fixedr  O  sK   	J	' *#5YY**1-44R8YY**1-44R8 Z4
 			$d!!4771Q36?
fh/d!"5771R47#
fh/ d"26772b5!8$
fh/ DD		#qc366!A;
vx0c466!B<
vx0 "))C.((11$v,'595a2aS56

 FF!QqSFF"bU*# *#N 6O*# *#s   H#J/J;AJJJ"c           
         t        t        j                  j                  d      j	                  d            }|j
                  D cg c]  }|d c}|_        |j                  D cg c]  }|d c}|_        t        |       5 }|j                  d|d       d}|j                  d|g      }t        j                  ||j                  d d |j                  d d f          d	}|j                  d|g      }t        j                  ||j                  d d |j                  d dd   f          d d d        y c c}w c c}w # 1 sw Y   y xY w)
Nrx   )2   d   3drP  rO   rL  zcolumns=df.columns[:75]K   zcolumns=df.columns[:75:2])r   r(   r   r   r   r"   r!   r   rS   r   r%   r   r   )r0   rU   rm   rb   critr   s         r4   test_select_filter_cornerr  }  s$   	299((+;;IF	GB#%88,a1R&	,BH%'ZZ0QrF)0BJ	J	' 	D5		'2g	.(gv.
fbffQ

3B-?&@A*gv.
fbffQ

5Bq50A-A&BC	D 	D -0	D 	Ds   D8'D=B*EEc                  @   t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D  cg c]  } d|  	 c}             t        j                  fdd	       }t        j                  |       y c c} w )
Nr   r   r   r   r   r   r    c                 *    j                  | d      S NrU   r   r   prU   s    r4   rA   z#test_path_pathlib.<locals>.<lambda>      "))A4)( rB   c                     t        | d      S NrU   r   r  s    r4   rA   z#test_path_pathlib.<locals>.<lambda>      HQ4E rB   
r   r(   r)   r*   r   r+   r-   r%   round_trip_pathlibr   r3   r   rU   s     @r4   test_path_pathlibr    s    	biin$$W--d6l#uRy1!r!X12
B ""(*EF "f% 2   Bzstart, stop))r   rx   )r$   rx   )NNc                 
   t        t        g d      t        g d      d      }t        |      5 }|j                  d|       |j	                  d| |      }t        j                  || | |       d d d        y # 1 sw Y   y xY w)N)i2i2i2)abcdr  r#   rl   test_datasetrl  )r   r	   r   r   r   r%   r   )rh  ri  r0   rU   rb   r   s         r4    test_contiguous_mixed_data_tabler    s~     
67*+	

B 
J	' 65^R(nEE
btnf5	6 6 6s   A A99Bc                  H   t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D  cg c]  } d|  	 c}             fd}d	 }t        j                  ||      }t        j                  |       y c c} w )
Nr   r   r   r   r   r   r    c                 l    t        |       5 }j                  |d       d d d        y # 1 sw Y   y xY wr  r   r   r1   rb   rU   s     r4   writerz*test_path_pathlib_hdfstore.<locals>.writer  1    d^ 	'uIIeI&	' 	' 	'   *3c                 \    t        |       5 }t        |d      cd d d        S # 1 sw Y   y xY wr  r   r1   rb   s     r4   readerz*test_path_pathlib_hdfstore.<locals>.reader  *    d^ 	)uE4(	) 	) 	)   "+r  r3   r  r  r   rU   s       @r4   test_path_pathlib_hdfstorer    s    	biin$$W--d6l#uRy1!r!X12
B') ""662F"f% 2   Bc                  @   t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D  cg c]  } d|  	 c}             t        j                  fdd	       }t        j                  |       y c c} w )
Nr   r   r   r   r   r   r    c                 *    j                  | d      S r  r  r  s    r4   rA   z,test_pickle_path_localpath.<locals>.<lambda>  r  rB   c                     t        | d      S r  r  r  s    r4   rA   z,test_pickle_path_localpath.<locals>.<lambda>  r  rB   r  r  s     @r4   test_pickle_path_localpathr    s    	biin$$W--d6l#uRy1!r!X12
B
 ""(*EF "f% 2r  c                  H   t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D  cg c]  } d|  	 c}             fd}d	 }t        j                  ||      }t        j                  |       y c c} w )
Nr   r   r   r   r   r   r    c                 l    t        |       5 }j                  |d       d d d        y # 1 sw Y   y xY wr  r  r  s     r4   r  z,test_path_localpath_hdfstore.<locals>.writer  r  r  c                 \    t        |       5 }t        |d      cd d d        S # 1 sw Y   y xY wr  r   r  s     r4   r  z,test_path_localpath_hdfstore.<locals>.reader  r  r  )
r   r(   r)   r*   r   r+   r-   r%   round_trip_localpathr   r  s       @r4   test_path_localpath_hdfstorer    s    	biin$$W--d6l#uRy1!r!X12
B') $$VV4F"f% 2r  propindexesTFc                 ~   t        dt        j                  d      j                  d      z  t	        t        d            t	        t        d      D cg c]  }d| 	 c}            }t        j                         5 }t        |      5 }|j                  d|d	g
       d d d        t        j                         5 }t        |      5 }t        j                  |j                  |j                   d |             5 }|j#                         }t%        |      t%        |j#                               k(  sJ |j#                         D ]  }	|j'                  |	      j(                  s|j'                  |	      }
|j'                  |	      }|j*                  |
j*                  k(  sJ | s_|j,                  D ]*  }|j.                  s|
|j                      j.                  r*J   	 d d d        d d d        d d d        d d d        y c c}w # 1 sw Y   exY w# 1 sw Y   4xY w# 1 sw Y   8xY w# 1 sw Y   <xY w# 1 sw Y   y xY w)Nr   r   r   r   r   r   r    rU   rr   r  )keysr  )r   r(   r)   r*   r   r+   r-   r%   r&   r   r   tempfileNamedTemporaryFile
contextlibclosingr  rQ  r  r   r   is_tablenrowsaxesr   )r  r3   rU   r1   stnew_frb   tstorer  knew_torig_tr#   s                r4   	test_copyr    s   	biin$$W--d6l#uRy1!r!X12
B 
	 Hdd^ 	4rIIdBcUI3	4((* 	He$ H5''JJuzz+JN H ::<Dt9FKKM(::::#[[] H!,,Q/88$*$5$5a$8E%*%5%5a%8F#)<<5;;#>>#>  +)/ !HA'(||/4QVV}/G/G(G/G!HHHH	HH H 2	4 	4H HH H	H 	HH Hs   G==H3	HH3;H'2H9A&H	 ?H	 H	<H	H	H$H',H3H	H3HHH$ H''H0	,H33H<c                 v   t        ddgddgg      }| |z  }d}t        j                  t        |      5  |j	                  |dd       d d d        |j	                  |dd	       t        |d      }t        j                  ||       |j                  |      sJ |j                  |      sJ y # 1 sw Y   fxY w)
Nr#   r   )r!   r  z/Columns index has to be unique for fixed formatr   rU   r  r   rO   )	r   r   r   r'   r   r   r%   r   equals)rT   r0   rU   r1   r   others         r4   test_duplicate_column_namer     s    	C:aVH	5Bj D
;C	z	- 2
		$D	12 IIdWI-T4 E"e$99U<<2 2s   B//B8c                    t        t        j                  j                  d      j	                  d            }t        dddd      |_        t        |       5 }||d	<   t        j                  |d	   |       d d d        y # 1 sw Y   y xY w)
Nrx   )re   r   )size0sre   1sexample)rh  rh   r   rQ  rU   )
r   r(   r   r   normalr   r"   r   r%   r   r0   rU   rb   s      r4   !test_preserve_timedeltaindex_typer    sw    	299((+222@	ABT2DyQBH	J	' /5d
eDk2./ / /s   B  B	c                    t        t        j                  j                  d      j                  d      t	        d      t	        d            }d|j
                  _        |j                  dd	      }|j
                  j                  |j                  j                         z   }| |z  }|j                  |d
dd|d       t	        d      }t	        |      }t        |d
|       ||k(  sJ y )Nrx   )r   r   abcdABCDE)r"   r!   lettersET)r  r   rU   r#   F)r   rN   r   rQ   r"   BCDr'  )r   r(   r   r   r+   r"   rQ  r  r,  r!   tolistr   r   )rT   r0   rU   rQ   r1   	cols2loadcols2load_originals          r4    test_columns_multiindex_modifiedr    s     

		a ''/6lW
B
 BHHM	3t	,B88>>BJJ$5$5$77Lj DII!   UIiT4+***rB   z3ignore:PeriodDtype\[B\] is deprecated:FutureWarningr!   r$   r   r   r   rf   rx   rg   z1 dayr  r   c                    t        t        j                  j                  d      j	                  d      |      }| |z  }d}t        j                  t        |      5  |j                  |ddd	       d d d        y # 1 sw Y   y xY w)
Nrx   rj  r'  z-cannot have non-object label DataIndexableColr   rU   rO   Tr   rP   rQ   )	r   r(   r   r   r   r   r   r'   r   )rT   r0   r!   rU   r1   r   s         r4   0test_to_hdf_with_object_column_names_should_failr  6  st     
299((+;;GDg	VBj D
9C	z	- E
		$Dt	DE E Es   A;;Br   categoryc                    t        t        j                  j                  d      j	                  d      t        ddg|            }| |z  }|j                  |ddd	
       t        |dd|j                  d    d      }t        |      sJ y )Nrx   rj  r#   rl   r   r'  rU   rO   Tr  z	index = [r   ]r   )
r   r(   r   r   r   r   r   r   r"   r.   )rT   r0   r   rU   r1   r   s         r4   /test_to_hdf_with_object_column_names_should_runr  J  s     

		a 009sCj.
B j DIIdW4I@dD)BHHQK=(BCFv;;rB   c                     t        g dg dd      }t        |       5 }|j                  d|       |d   j                  j                  |d   d   j                  j                  k(  sJ 	 d d d        y # 1 sw Y   y xY w)N)r$   rx   r   r   )r   r   r   r   r  rU   r#   )r   r   rS   rn  stridesr  s      r4   test_hdfstore_stridesr  W  ss    	L9	:B	J	' I5		$#w~~%%tS)9)@)@)H)HHHHI I Is   AA33A<c                     t        dggdgt        dgd            }|j                         }| |z  }|j                  |d       t	        |d      }t        j                  ||       y )	Nr$   TFboolr   r    r#   r  )r   r   r  r   r   r%   r   )rT   r0   rU   r   r1   r   s         r4   test_store_bool_indexr  _  sb    	QC54&ugV0L	MBwwyH j DIIdIdC F(F+rB   )Vr  r   r   rX   r  rZ   numpyr(   r   pandas._configr   pandas.compatr   pandasr   r   r   r   r   r	   r
   r   r   r   r   pandas._testing_testingr%   pandas.tests.io.pytables.commonr   r   pandas.io.pytablesr   r   mark
single_cpu
pytestmarkimportorskipr   r5   r`   rc   r   r   r   parametrizer   r   r   r   r   r  xfailr  r$  r(  r1  r6  rD  rJ  rN  rS  r\  r_  ra  rw  r{  r  r  r  r  r  r  r  r  r  r  r  r  filterwarningsint64rj   r  r  r  r   rB   r4   <module>r     s_          - %    

 kk$$%
			X	&/$(4V!:z "F! H  #^4ce<!$ 7#0/E4=!A.1eeW-=		
 #0/E4=!A.1eeW-=	
*%<+*%<P$B86O0 ([N   GW#56( 7	
(+B?D0=4*6*Z0.* l34'7);<- = 5-6//s0l0,0+#\D"
& (FG6 H6 &&	&&& u6H 7HB /+8 RSq!fBHH%sCj

+<++\137	E	 TE 4"45	 6	I
,rB   