o
    թZh_5                  
   @   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dataZorc )datapathr   r   O/var/www/html/lang_env/lib/python3.10/site-packages/pandas/tests/io/test_orc.pydirpath   s   r         Zuint64dtype)abr   category   )leftright   z
2022-01-03D)freqz
2022-01-04)paramsc                 C   s   t d| jiS )NZunimpl)pd	DataFrameparam)requestr   r   r
   orc_writer_dtypes_not_supported   s   r   c                 C   sp   g d}g d}t jt dd}t||D ]\}}t j|d||< qtj| d}t||d}t	
|| d S )N	Zboolean1Zbyte1Zshort1int1Zlong1Zfloat1Zdouble1Zbytes1string1)	boolint8int16int32int64float32float64objectr)   r   indexr   zTestOrcFile.emptyFile.orccolumns)r   r   
RangeIndexzipSeriesospathjoinr   tmassert_equal)r   r-   ZdtypesexpectedZcolnamer   	inputfilegotr   r   r
   test_orc_reader_empty-   s   r9   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%       r&         ?       @r'         .      r(           r)   hibyer   zTestOrcFile.test1.orcr,   )nparrayr   r   	from_dictr1   r2   r3   r   keysr4   r5   r   r   r6   r7   r8   r   r   r
   test_orc_reader_basicN   s   rL   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 )NZ_col0z-1000.50000z
-999.60000z
-998.70000z
-997.80000z
-996.90000z
-995.10000z
-994.11000z
-993.12000z
-992.13000z
-991.14000r)   r   zTestOrcFile.decimal.orc
   )rG   rH   r   r   r   rI   r1   r2   r3   r   ilocr4   r5   rK   r   r   r
   test_orc_reader_decimalb   s&   rO   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        r)   timedatezTestOrcFile.testDate1900.orcrM   rG   rH   datetimerV   r   r   rI   r1   r2   r3   r   rN   r4   r5   rK   r   r   r
   test_orc_reader_date_low}   .    rY   c                 C   rP   )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.100900rQ   r   i  rR   rS   r)   rT   zTestOrcFile.testDate2038.orcrM   rW   rK   r   r   r
   test_orc_reader_date_high   rZ   r[   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   )
Zf50dcb8Z382fdaaaZ90758c6Z9e8caf3fZee97332bZd634da1Z2bea4396Zd67d89e8Zad71007eZe8c82066r)   )r    r!   zTestOrcFile.testSnappy.orcrM   )rG   rH   r   r   rI   r1   r2   r3   r   rN   r4   r5   rK   r   r   r
   !test_orc_reader_snappy_compressed   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|| W d    d S 1 suw   Y  d S NpyarrowFTr"   r   r   r:   r#   r;   r<   r$   r=   r%   r>   r&   r?   r@   r'   rA   rB   r(   rC   rD   r)   rE   rF   r   )pytestimportorskiprG   rH   r   r   rI   r4   ensure_cleanto_orcr   r5   )r   r   r6   r2   r8   r   r   r
   test_orc_roundtrip_file   s"   


"rc   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 r]   )r_   r`   rG   rH   r   r   rI   rb   r   r   r4   r5   )r   r6   bytesr8   r   r   r
   test_orc_roundtrip_bytesio  s   
re   c                 C   sJ   t d d}t jt|d |   W d    d S 1 sw   Y  d S )Nr^   z6The dtype of one or more columns is not supported yet.match)r_   r`   raisesNotImplementedErrorrb   )r   msgr   r   r
   $test_orc_writer_dtypes_not_supported)  s
   

"rk   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 }t|| d S )Nr^   abcr   cr   Nrm   )s   foos   barNr            @      @r(   r   r@         @TFTTFNZ20130101   )ZperiodsZ20130103)stringstring_with_nanstring_with_nonerd   intfloatfloat_with_nanr"   bool_with_narX   Zdatetime_with_natZdtype_backendc              	      s(   i | ]}|t jtj | d dqS )T)Zfrom_pandas)r   ZarraysZArrowExtensionArrayparH   ).0coldfr   r
   
<dictcomp>M  s    z2test_orc_dtype_backend_pyarrow.<locals>.<dictcomp>)r_   r`   r   r   listrG   nanrangearangeZ
date_range	TimestampZNaTcopyrb   r   r   r-   r4   assert_frame_equal)
bytes_dataresultr6   r   r   r
   test_orc_dtype_backend_pyarrow3  s4   



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 )Nr^   rl   r   rm   rn   r   ro   ru   ZInt64r   rp   rq   r(   r@   rr   rs   rt   )
rv   rw   rx   ry   Zint_with_nanZna_onlyrz   r{   r"   r|   Znumpy_nullabler}   )r   r   rm   r   r   ru   )rp   g      @g      @ZFloat64booleanTF)r_   r`   r   r   r   rG   r   r   r0   ZNAr   r   rb   r   r   r   rH   Zobject_r4   r   )r   r   r   r6   r   r   r
   %test_orc_dtype_backend_numpy_nullableV  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 )Nry   r   ro   tmp.orc)r   r   r   r   r4   ra   rb   pathlibPathas_urir   r   )r6   r2   urir   r   r   r
   test_orc_uri_path  s   

r   r+   )startstopstepru   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   r*   z[orc does not support serializing a non-default index|orc does not serialize index meta-datarf   )r   r   r_   rh   
ValueErrorrb   )r+   r   rj   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.ry   r   ro   r   rf   numpyr}   )r   r   r   r   r4   ra   rb   r_   rh   r   r   )rj   r   r2   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dt jdgdd	d
}t|| d S )Nztest_string_inference.pr   xy)r   zfuture.infer_stringTzstring[pyarrow_numpy]r   )r   r   r-   )r   r   rb   Zoption_contextr   Indexr4   r   )Ztmp_pathr2   r   r   r6   r   r   r
   test_string_inference  s   


r   )2__doc__rX   decimalr   r   r   r1   r   r   rG   r_   Zpandasr   r   Zpandas._testingZ_testingr4   Zpandas.core.arraysr   r`   r^   r~   markfilterwarningsZ
pytestmarkZfixturer   rH   r0   ZIntervalZPeriodr   r9   rL   rO   rY   r[   r\   rc   re   rk   r   r   r   Zparametrizer.   r   r   r   r   r   r   r   r
   <module>   sb    


!)))
#+	

