o
    vh7                  
   @   s  d Z ddlZddlmZ ddlm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mZ e
d ddlZe
jdZe
jd	d
 Ze
je	jddgddejg dddejdddejdddgejdddejdddggddd Zdd Z dd Z!dd  Z"d!d" Z#d#d$ Z$d%d& Z%d'd( Z&d)d* Z'd+d, Z(d-d. Z)d/d0 Z*d1d2 Z+e
j,d3ej-dddd4ej-dd5dd6d7e.g d8gd9d: Z/d;d< Z0d=d> Z1dS )?z test orc compat     N)Decimal)BytesIO)read_orc)StringArrayzpyarrow.orcz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningc                 C   s   | dddS )Niodataorc )datapathr	   r	   V/var/www/html/hyperkenya/venv/lib/python3.10/site-packages/pandas/tests/io/test_orc.pydirpath   s   r         uint64dtype)abr   category   )leftright   z
2022-01-03D)freqz
2022-01-04)paramsc                 C   s   t d| jiS )Nunimpl)pd	DataFrameparam)requestr	   r	   r   orc_writer_dtypes_not_supported   s   r!   c           	   	   C   s   g d}dddddddd	|rd
nd	g	}t jt dd}t||D ]\}}t j|d||< q!|jd
|_tj	| d}t
||d}t|| d S )N	boolean1byte1short1int1long1float1double1bytes1string1boolint8int16int32int64float32float64objectstrr   indexr   zTestOrcFile.emptyFile.orccolumns)r   r   
RangeIndexzipSeriesr8   astypeospathjoinr   tmassert_equal)	r   using_infer_stringr8   dtypesexpectedcolnamer   	inputfilegotr	   r	   r   test_orc_reader_empty-   s$   
rH   c                 C   s   t jddgddt jddgddt jdd	gd
dt jddgddt jddgddt jddgddt jddgddt jddgddt jddgddd	}tj|}tj| d}t||	 d}t
|| d S )NFTr,   r   r   d   r-         r.      r/       r0         ?       @r1         .      r2           r3   hibyer"   zTestOrcFile.test1.orcr7   )nparrayr   r   	from_dictr=   r>   r?   r   keysr@   rA   r   r   rD   rF   rG   r	   r	   r   test_orc_reader_basicO   s   r[   c                 C   s   dt jtdtdtdtdtdtdtdtd	td
tdg
ddi}tj|}tj| d}t	|j
d d }t|| d S )N_col0z-1000.50000z
-999.60000z
-998.70000z
-997.80000z
-996.90000z
-995.10000z
-994.11000z
-993.12000z
-992.13000z
-991.14000r3   r   zTestOrcFile.decimal.orc
   )rV   rW   r   r   r   rX   r=   r>   r?   r   ilocr@   rA   rZ   r	   r	   r   test_orc_reader_decimalc   s&   r_   c                 C      t jg dddt jtdddtdddtdddtdddtdddtdddtdddtdddtdddtdddg
ddd}tj|}tj	| d	}t
|jd d
 }t|| d S )N)
z1900-05-05 12:34:56.100000z1900-05-05 12:34:56.100100z1900-05-05 12:34:56.100200z1900-05-05 12:34:56.100300z1900-05-05 12:34:56.100400z1900-05-05 12:34:56.100500z1900-05-05 12:34:56.100600z1900-05-05 12:34:56.100700z1900-05-05 12:34:56.100800z1900-05-05 12:34:56.100900datetime64[ns]r   il        r3   timedatezTestOrcFile.testDate1900.orcr]   rV   rW   datetimerf   r   r   rX   r=   r>   r?   r   r^   r@   rA   rZ   r	   r	   r   test_orc_reader_date_low~   .    ri   c                 C   r`   )N)
z2038-05-05 12:34:56.100000z2038-05-05 12:34:56.100100z2038-05-05 12:34:56.100200z2038-05-05 12:34:56.100300z2038-05-05 12:34:56.100400z2038-05-05 12:34:56.100500z2038-05-05 12:34:56.100600z2038-05-05 12:34:56.100700z2038-05-05 12:34:56.100800z2038-05-05 12:34:56.100900ra   r   i  rb   rc   r3   rd   zTestOrcFile.testDate2038.orcr]   rg   rZ   r	   r	   r   test_orc_reader_date_high   rj   rk   c                 C   sb   t jg dddt jg dddd}tj|}tj| d}t|j	d d }t
|| d S )	N)
iEAںijFiA!{i~iY5B
irhi;Sinqi:i(r/   r   )
f50dcb8382fdaaa90758c69e8caf3fee97332bd634da12bea4396d67d89e8ad71007ee8c82066r3   )r&   r+   zTestOrcFile.testSnappy.orcr]   )rV   rW   r   r   rX   r=   r>   r?   r   r^   r@   rA   rZ   r	   r	   r   !test_orc_reader_snappy_compressed   s    rv   c                 C   s   t d tjddgddtjddgddtjd	d
gddtjddgddtjddgddtjddgddtjddgddtjddgddtjddgddd	}tj|}t }|	| t
|}t|| W d    d S 1 suw   Y  d S NpyarrowFTr,   r   r   rI   r-   rJ   rK   r.   rL   r/   rM   r0   rN   rO   r1   rP   rQ   r2   rR   rS   r3   rT   rU   r"   )pytestimportorskiprV   rW   r   r   rX   r@   ensure_cleanto_orcr   rA   )r   r   rD   r>   rG   r	   r	   r   test_orc_roundtrip_file   s"   


"r}   c                  C   s   t d tjddgddtjddgddtjd	d
gddtjddgddtjddgddtjddgddtjddgddtjddgddtjddgddd	} tj| }| }tt	|}t
|| d S rw   )ry   rz   rV   rW   r   r   rX   r|   r   r   r@   rA   )r   rD   bytesrG   r	   r	   r   test_orc_roundtrip_bytesio  s   
r   c                 C   sJ   t d d}t jt|d |   W d    d S 1 sw   Y  d S )Nrx   z6The dtype of one or more columns is not supported yet.match)ry   rz   raisesNotImplementedErrorr|   )r!   msgr	   r	   r   $test_orc_writer_dtypes_not_supported*  s
   

"r   c                    s  t d ttddtjdgg dg dttddtjd	d
dddtjdgg dg dtj	dddt
dtjt
dgd    }tt|dd}t fdd jD }| rtt }|d ||d< |d ||d< |d ||d< t|| d S )Nrx   abcr   cr   Nr   )s   foos   barNr            @      @r2   r   rO         @TFTTFN20130101   )periods20130103)stringstring_with_nanstring_with_noner~   intfloatfloat_with_nanr,   bool_with_narh   datetime_with_natdtype_backendc              	      s(   i | ]}|t jtj | d dqS )T)from_pandas)r   arraysArrowExtensionArrayparW   ).0coldfr	   r   
<dictcomp>N  s    z2test_orc_dtype_backend_pyarrow.<locals>.<dictcomp>r   r   r   )ry   rz   r   r   listrV   nanrangearange
date_range	TimestampNaTcopyr|   r   r   r8   
ArrowDtyper   r   r<   r@   assert_frame_equal)rB   
bytes_dataresultrD   string_dtyper	   r   r   test_orc_dtype_backend_pyarrow4  s>   



r   c                  C   s  t d ttddtjdgg dttddtjdtj	dgd	d
tjtj	tj	tj	gd	d
tj
dddd
dtjdgg dg dd
} |   }tt|dd}tttjg dtjd
ttjdtj	dgtjd
ttjdtj	dgtjd
tjg dd	d
tjdtj	dgd	d
tjtj	tj	tj	gd	d
tjg ddd
tjdtj	dgdd
tjg ddd
tjddtj	gdd
d
}t|| d S )Nrx   r   r   r   r   r   r   r   Int64r   r   r   r2   rO   r   r   r   )
r   r   r   r   int_with_nanna_onlyr   r   r,   r   numpy_nullabler   )r   r   r   r   r   r   )r   g      @g      @Float64booleanTF)ry   rz   r   r   r   rV   r   r   r;   NAr   r   r|   r   r   r   rW   object_r@   r   )r   r   r   rD   r	   r	   r   %test_orc_dtype_backend_numpy_nullable^  sD   


r   c                  C   sr   t dttddi} td}| | t|	 }t
|}W d    n1 s,w   Y  t||  d S )Nr   r   r   tmp.orc)r   r   r   r   r@   r{   r|   pathlibPathas_urir   r   )rD   r>   urir   r	   r	   r   test_orc_uri_path  s   

r   r6   )startstopstepr   znon-default)r   r   r   namer   c                 C   sV   t jdg di| d}d}tjt|d |  W d    d S 1 s$w   Y  d S )Nr   r   r5   z[orc does not support serializing a non-default index|orc does not serialize index meta-datar   )r   r   ry   r   
ValueErrorr|   )r6   r   r   r	   r	   r   test_to_orc_non_default_index  s   	
"r   c               	   C   s   d} t dttddi}td3}|| tjt	| d t
|dd W d    n1 s1w   Y  W d    d S W d    d S 1 sIw   Y  d S )	NzPdtype_backend numpy is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.r   r   r   r   r   numpyr   )r   r   r   r   r@   r{   r|   ry   r   r   r   )r   r   r>   r	   r	   r   test_invalid_dtype_backend  s   
"r   c                 C   s   | d }t jdddgid}|| t dd t|}W d    n1 s(w   Y  t jdddgit jtjdt jdgt jtjdd	d
}t	
|| d S )Nztest_string_inference.pr   xy)r   zfuture.infer_stringT)na_valuer   )r   r   r8   )r   r   r|   option_contextr   StringDtyperV   r   Indexr@   r   )tmp_pathr>   r   r   rD   r	   r	   r   test_string_inference  s   


r   )2__doc__rh   decimalr   r   r   r=   r   r   rV   ry   pandasr   r   pandas._testing_testingr@   pandas.core.arraysr   rz   rx   r   markfilterwarnings
pytestmarkfixturer   rW   r;   IntervalPeriodr!   rH   r[   r_   ri   rk   rv   r}   r   r   r   r   r   parametrizer9   r   r   r   r   r	   r	   r	   r   <module>   sb    


")))
*+	

