
    g                         d dl Z 	 d dlZd dlZd dlmZ d Zd Z		 	 ddZ
ddZd Zd Zd	 Zdd
Zd ZddZy# e$ r dZY 8w xY w)    N)utilc                     dd l m} ddlm} |j	                  |       rt
        j                  j                  |       }  |j                  | |fi | | S )Nr   )_pandas_api)	pyarrow.parquetparquetpyarrow.pandas_compatr   is_data_framepaTablefrom_pandaswrite_table)tablepathkwargspqr   s        Q/var/www/openai/venv/lib/python3.12/site-packages/pyarrow/tests/parquet/common.py_write_tabler      sD     1  '$$U+BNN5$)&)L    c                  Z    dd l m}  |j                  | i |}|j                  d       |S )Nr   T)full)r   r   
read_tablevalidate)argsr   r   r   s       r   _read_tabler   )   s-     BMM4*6*E	NNNLr   c                     |xs i }|xs i }t        j                         }t        | |fi | t        j                  |j	                               }t        |fi |S )N)r
   BufferOutputStreamr   BufferReadergetvaluer   )r   read_table_kwargswrite_table_kwargswriterreaders        r   _roundtrip_tabler#   1   s\    )/R+1r""$F5"45__V__./Fv3!233r   c                     || }|xs i }t        | ||      }|j                  |      sJ t        |||      }|j                  |      sJ y )N)r   r    )r#   equals)r   expectedr   r    results        r   _check_roundtripr(   <   sd    )/R e7H1CEF=="""f8I1CEF=="""r   c                 z    t         j                  j                  |       }t        ||      }|j	                         S )N)r    )r
   r   r   r#   	to_pandas)dfwrite_kwargsr   r'   s       r   _roundtrip_pandas_dataframer-   L   s4    HH  $E,0Fr   c                    t        j                  d      }t        j                  |      }t         j                  j                  t	        |j
                  |j
                        t        |j                  |j                        | |      S )Nint_sizedtype)npiinforandomrandintmaxmin)r1   r2   platform_int_infor4   s       r   _random_integersr:   S   sh    (HHUOE99S,=,A,AB ,=,A,AB"&e  5 5r   c                 V    t        j                  t        j                  | |            S )Nr2   )r
   arrayr3   aranger0   s     r   _range_integersr?   \   s    88BIId%011r   c                 t   dd l }t        j                  j                  |       |j	                  t        | t        j                        t        | t        j                        t        | t        j                        t        | t        j                        t        | t        j                        t        | t        j                        t        | t        j                        t        | t        j                        t        j                  j                  |       j                  t        j                         t        j"                  | t        j$                        t        j                  j                  |       dkD  t'        |       D cg c]  }t)        j*                  d       c}d g| z  d g| z  d      }|S c c}w )Nr   r<   
   )uint8uint16uint32uint64int8int16int32int64float32float64boolstringsall_noneall_none_category)pandasr3   r5   seed	DataFramer:   rB   rC   rD   rE   rF   rG   rH   rI   randnastyperJ   r>   rK   ranger   rands)r1   rQ   pdir+   s        r   _test_dataframerY   `   s   IINN4	!$1"43"43"43 rww/!$1!$1!$199??4(//

;99T4		%),1$K8KqDJJrNK8FTM"Vd] 
B& I 9s   F5c                    dd l m} t        | t        j                        r| }nt        j                  j                  |       }t        j                         }t        ||dd       |j                  d       |j                  |      S )Nr   SNAPPYz2.6)compressionversion)r   r   
isinstancer
   r   r   ioBytesIOr   seekParquetFile)table_or_dfr   a_tablebufs       r   make_sample_filerf   z   s_     +rxx(((&&{3
**,C#8UCHHQK>>#r   c                 8   dd l }t        j                  j                  |       i dt        j                  | t        j
                        dt        j                  | t        j                        dt        j                  | t        j                        dt        j                  | t        j                        dt        j                  | t        j                        dt        j                  | t        j                        d	t        j                  | t        j                        d
t        j                  | t        j                        dt        j                  | t        j                        dt        j                  | t        j                        dt        j                  | t        j                        dt        j                  j                  |       dkD  dt        j                  d| d      dt        j                  d| d      dt        j                  d| d      dt        j                  d| d      d|j!                  t#        |       D cg c]  }t%        |       c}      dg| z  d gt#        | dz
        D cg c]  }t%        |       c}z   d gz   d g| z  d gdz  t#        | dz
        D cg c]  }d g|dz  z   c}z   d}|r|d   j'                  d      |d <   |j)                  |      S c c}w c c}w c c}w )!Nr   rB   r<   rC   rD   rE   rF   rG   rH   rI   float16rJ   rK   rL   datetime_msz2016-01-01T00:00:00.001zdatetime64[ms]datetime_usz2016-01-01T00:00:00.000001zdatetime64[us]datetime_nsz2016-01-01T00:00:00.000000001zdatetime64[ns]	timedeltaztimedelta64[s]str       )	empty_strstr_with_nullsnull	null_listcategorystr_category)rP   r3   r5   rQ   r>   rB   rC   rD   rE   rG   rH   rI   rh   rJ   rK   rS   SeriesrU   rm   rT   rR   )r1   rQ   categoricalrW   xarrayss         r   alltypes_sampler{      s   IINN44rxx0"))D		2 	"))D		2 	"))D		2	
 			$bhh/ 	4rxx0 	4rxx0 	4rxx0 	299T4 	299T4 	299T4 			%) 	ryy!:D'79 	ryy!=t'79" 	ryy!@$'79#& 	RYYq$.>?'( 	ryy%+6+Q#a&+67)* TD[&E$(O#DOqCFO#DDvMVaZU4!8_"M_D6QU#3_"MM1F4 !'!5!5j!A~<< 7#D"Ms   'LL
L)NN)'  r   )r|   r   F)r_   numpyr3   ImportErrorpyarrowr
   pyarrow.testsr   r   r   r#   r(   r-   r:   r?   rY   rf   r{    r   r   <module>r      sk   $ 
  	 /3(,4# 524  g  	Bs   9 AA