o
    S+ i#                     @  sJ  d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ G dd dZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZejdd Zejdd ZeZeZeZeZegZeegZejeejjejj e ddgdgZ!g eee!Z"dgZ#ddgZ$dgZ%g e$e#e%Z&eje"e&ddd Z'ejee$dd d! Z(ejee#dd"d# Z)eje!e%dd$d% Z*d&d' Z+eje+ d( e+ d) dd*d+ Z,g d,Z-g d-Z.d.d/gZ/d0d1 e.D Z0eje-d2d3d4 Z1eje0d2d5d6 Z2ejg d7d2d8d9 Z3ejd:d; Z4ejd<d= Z5dS )>    )annotationsN)HAS_PYARROW)VERSIONS)read_csv
read_tablec                   @  sd   e Zd ZU dZded< dZg Zded< dd Zd	d
 ZddddddZ	dd Z
dddddZdS )
BaseParserNz
str | NoneengineTzlist[str | None]float_precision_choicesc                 C  s    |  }|| j| jd |S )N)r   
low_memory)copyupdater   r
   )selfkwargs r   k/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/pandas/tests/io/parser/conftest.pyupdate_kwargs   s   zBaseParser.update_kwargsc                 O     |  |}t|i |S N)r   r   r   argsr   r   r   r   r         
zBaseParser.read_csv)raise_on_extra_warningscheck_stacklevel	warn_typetype[Warning]warn_msgstrr   boolc                O  sN   |  |}tj||||d t|i |W  d    S 1 s w   Y  d S )N)matchr   r   )r   tmassert_produces_warningr   )r   r   r   r   r   r   r   r   r   r   read_csv_check_warnings    s   
$z"BaseParser.read_csv_check_warningsc                 O  r   r   )r   r   r   r   r   r   r   5   r   zBaseParser.read_table)r   c                O  sL   |  |}tj|||d t|i |W  d    S 1 sw   Y  d S )N)r   r   )r   r   r    r   )r   r   r   r   r   r   r   r   r   read_table_check_warnings9   s   
$z$BaseParser.read_table_check_warnings)r   r   r   r   r   r   )r   r   r   r   )__name__
__module____qualname__r   __annotations__r
   r	   r   r   r!   r   r"   r   r   r   r   r      s   
 		r   c                   @  s   e Zd ZdZg dZdS )CParserc)NhighZ
round_tripNr#   r$   r%   r   r	   r   r   r   r   r'   K   s    r'   c                   @     e Zd ZdZdS )CParserHighMemoryFNr#   r$   r%   r
   r   r   r   r   r,   P       r,   c                   @  r+   )CParserLowMemoryTNr-   r   r   r   r   r/   T   r.   r/   c                   @     e Zd ZdZdgZdS )PythonParserpythonNr*   r   r   r   r   r1   X       
r1   c                   @  r0   )PyArrowParserpyarrowNr*   r   r   r   r   r4   ]   r3   r4   c                 C  s   | dddS )zG
    The directory path to the data files needed for parser tests.
    ioparserdatar   datapathr   r   r   csv_dir_pathb   s   r;   c                 C  s   t j| ddddS )zH
    The path to the data file "test1.csv" needed for parser tests.
    r6   r8   csvz	test1.csv)ospathjoinr9   r   r   r   csv1j   s   r@   pyarrow is not installedreasonZmarksr2   Zc_highZc_lowr5   paramsidsc                 C  s8   |   }|jdkrtdtd  ddl}|d |S )z)
    Fixture all of the CSV parsers.
    r5   r   N   )paramr   pytestZimportorskipr   r5   Zset_cpu_count)requestr7   r5   r   r   r   all_parsers   s   

rL   c                 C     |   S )z<
    Fixture all of the CSV parsers using the C engine.
    rI   rK   r   r   r   c_parser_only      rP   c                 C  rM   )zA
    Fixture all of the CSV parsers using the Python engine.
    rN   rO   r   r   r   python_parser_only   rQ   rR   c                 C  rM   )zB
    Fixture all of the CSV parsers using the Pyarrow engine.
    rN   rO   r   r   r   pyarrow_parser_only   rQ   rS   c                  C  s   g } g }t ttD ]A\}}t|dr|jd }|jD ]/}|jdkr.tjj	tjj
t ddgnd}tj| |f|d}| | || d|  qq	| |d	S )
za
    Return all allowable parser and float precision
    combinations and corresponding ids.
    valuesr   r5   rA   rB   r   rD   -rE   )zip_all_parsers_all_parser_idshasattrrT   r	   r   rJ   mark
single_cpuskipifr   rI   append)rF   rG   r7   Z	parser_id	precisionrZ   rI   r   r   r   ,_get_all_parser_float_precision_combinations   s&   



	


r_   rF   rG   c                 C     | j S )zR
    Fixture for all allowable combinations of parser
    and float precision
    rN   rO   r   r   r   all_parsers_all_precisions   s   	ra   )          ) rU   _utfZUTFc                 C  s$   g | ]}t D ]	}| | d qqS )z{0})_encoding_prefixes).0sepprefixr   r   r   
<listcomp>   s
    rl   )rF   c                 C  r`   )zE
    Fixture for all possible integer values for a UTF encoding.
    rN   rO   r   r   r   	utf_value      rm   c                 C  r`   )zD
    Fixture for all possible string formats of a UTF encoding.
    rN   rO   r   r   r   encoding_fmt   rn   ro   )*)z-1,0      )z-1,2e0g333333)z-1e0rp   )z+1e0      ?)z+1e+0rq   )z+1e-1皙?)z+,1e1rq   )z+1,e0rq   )z-,1e1rp   )z-1,e0rp   )z0,1rr   )z1,rq   )z,1rr   )z-,1g)z1_,rq   )z1_234,56
ףp=J@)z
1_234,56e0rs   )rf   rf   )-_rt   )-_1ru   )-_1e0rv   )_1rw   )_1,rx   )_1,_ry   )_1e0rz   )1,2e_1r{   )1,2e1_0r|   )1,_2r}   ),1__2r~   ),1er   )-,1er   )1_000,000_000r   )1,e1_2r   )e11,2r   )1e11,2r   )1,2,2r   )1,2_1r   )	1,2e-10e1r   )--1,2r   )1a_2,1r   )z1,2E-1gQ?)z1,2E1g      (@c                 C  r`   )z
    Fixture for all numeric formats which should get recognized. The first entry
    represents the value to read while the second represents the expected result.
    rN   rO   r   r   r   numeric_decimal   s   4r   c                 C  s^   d| j v r| d}nd| j v r| dd }ndS |jdkr-tjjdd}| | dS dS )z
    Fixture that xfails a test if the engine is pyarrow.

    Use if failure is do to unsupported keywords or inconsistent results.
    rL   ra   r   Nr5   zpyarrow doesn't support this.rB   )fixturenamesgetfixturevaluer   rJ   rZ   ZxfailZapplymarker)rK   r7   rZ   r   r   r   pyarrow_xfail/  s   


r   c                 C  sR   d| j v r| d}nd| j v r| dd }ndS |jdkr'tjdd dS dS )z
    Fixture that skips a test if the engine is pyarrow.

    Use if failure is do a parsing failure from pyarrow.csv.read_csv
    rL   ra   r   Nr5   z,https://github.com/apache/arrow/issues/38676rB   )r   r   r   rJ   skip)rK   r7   r   r   r   pyarrow_skipB  s   


r   )6
__future__r   r=   rJ   Zpandas.compatr   Zpandas.compat._optionalr   Zpandasr   r   Zpandas._testingZ_testingr   r   r'   r,   r/   r1   r4   Zfixturer;   r@   Z_cParserHighMemoryZ_cParserLowMemoryZ_pythonParserZ_pyarrowParserZ_py_parsers_onlyZ_c_parsers_onlyrI   rZ   r[   r\   Z_pyarrow_parsers_onlyrW   Z_py_parser_idsZ_c_parser_idsZ_pyarrow_parsers_idsrX   rL   rP   rR   rS   r_   ra   Z_utf_valuesZ_encoding_sepsrh   Z_encoding_fmtsrm   ro   r   r   r   r   r   r   r   <module>   s    :












/
