U
    sVc                  +   @  st  d dl mZ d dlZd dl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dgZeeeZdgZ ddgZ!dgZ"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)d)d*d+gZ*d,d-d.gZ+d/d0gZ,d1d2 e+D Z-eje*d3d4d5 Z.eje-d3d6d7 Z/ejd8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dag*d3dbdc Z0ejddde Z1ejdfdg Z2dS )h    )annotationsN)VERSIONS)read_csv
read_tablec                   @  sb   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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   C/tmp/pip-unpacked-wheel-xj8nt62q/pandas/tests/io/parser/conftest.pyupdate_kwargs   s    zBaseParser.update_kwargsc                 O  s   |  |}t||S N)r   r   r   argsr   r   r   r   r      s    
zBaseParser.read_csvztype[Warning]str)	warn_typewarn_msgc              
   O  s:   |  |}tj||d t||W  5 Q R  S Q R X d S N)match)r   tmassert_produces_warningr   r   r   r   r   r   r   r   r   read_csv_check_warnings   s    
z"BaseParser.read_csv_check_warningsc                 O  s   |  |}t||S r   )r   r   r   r   r   r   r   )   s    
zBaseParser.read_tablec              
   O  s:   |  |}tj||d t||W  5 Q R  S Q R X d S r   )r   r   r   r   r   r   r   r   read_table_check_warnings-   s    
z$BaseParser.read_table_check_warnings)__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dddgZdS )CParsercNhighZ
round_tripr   r   r    r   r   r   r   r   r   r"   8   s   r"   c                   @  s   e Zd ZdZdS )CParserHighMemoryFNr   r   r    r	   r   r   r   r   r&   =   s   r&   c                   @  s   e Zd ZdZdS )CParserLowMemoryTNr'   r   r   r   r   r(   A   s   r(   c                   @  s   e Zd ZdZdgZdS )PythonParserpythonNr%   r   r   r   r   r)   E   s   r)   c                   @  s   e Zd ZdZdgZdS )PyArrowParserpyarrowNr%   r   r   r   r   r+   J   s   r+   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_pathO   s    r2   c                 C  s   t j| ddddS )zH
    The path to the data file "test1.csv" needed for parser tests.
    r-   r/   csvz	test1.csv)ospathjoinr0   r   r   r   csv1W   s    r7   Zmarksr*   Zc_highZc_lowr,   paramsidsc                 C  s8   |   }|jdkr4tdtd  ddl}|d |S )z)
    Fixture all of the CSV parsers.
    r,   r   N   )paramr   pytestZimportorskipr   r,   Zset_cpu_count)requestr.   r,   r   r   r   all_parsersq   s    

r@   c                 C  s   |   S )z<
    Fixture all of the CSV parsers using the C engine.
    r=   r?   r   r   r   c_parser_only   s    rC   c                 C  s   |   S )zA
    Fixture all of the CSV parsers using the Python engine.
    rA   rB   r   r   r   python_parser_only   s    rD   c                 C  s   |   S )zB
    Fixture all of the CSV parsers using the Pyarrow engine.
    rA   rB   r   r   r   pyarrow_parser_only   s    rE   c                  C  s   g } g }t ttD ]p\}}t|dr.|jd }|jD ]L}|jdkrJtjj	nd}tj
| |f|d}| | || d|  q4q| |dS )za
    Return all allowable parser and float precision
    combinations and corresponding ids.
    valuesr   r,   r   r8   -r9   )zip_all_parsers_all_parser_idshasattrrF   r   r   r>   mark
single_cpur=   append)r:   r;   r.   Z	parser_idZ	precisionrL   r=   r   r   r   ,_get_all_parser_float_precision_combinations   s    



rO   r:   r;   c                 C  s   | j S )zR
    Fixture for all allowable combinations of parser
    and float precision
    rA   rB   r   r   r   all_parsers_all_precisions   s    	rP              rG   _utfZUTFc                 C  s&   g | ]}t D ]}| | d  qqS )z{0})_encoding_prefixes).0sepprefixr   r   r   
<listcomp>   s      r[   )r:   c                 C  s   | j S )zE
    Fixture for all possible integer values for a UTF encoding.
    rA   rB   r   r   r   	utf_value   s    r\   c                 C  s   | j S )zD
    Fixture for all possible string formats of a UTF encoding.
    rA   rB   r   r   r   encoding_fmt   s    r]   )z-1,0      )z-1,2e0g333333)z-1e0r^   )z+1e0      ?)z+1e+0r_   )z+1e-1皙?)z+,1e1r_   )z+1,e0r_   )z-,1e1r^   )z-1,e0r^   )z0,1r`   )z1,r_   )z,1r`   )z-,1g)z1_,r_   )z1_234,56
ףp=J@)z
1_234,56e0ra   )rU   rU   )-_rb   )-_1rc   )-_1e0rd   )_1re   )_1,rf   )_1,_rg   )_1e0rh   )1,2e_1ri   )1,2e1_0rj   )1,_2rk   ),1__2rl   ),1erm   )-,1ern   )1_000,000_000ro   )1,e1_2rp   )e11,2rq   )1e11,2rr   )1,2,2rs   )1,2_1rt   )	1,2e-10e1ru   )--1,2rv   )1a_2,1rw   )z1,2E-1gQ?)z1,2E1g      (@c                 C  s   | j S )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.
    rA   rB   r   r   r   numeric_decimal   s    4rx   c                 C  s\   d| j kr| d}nd| j kr0| dd }ndS |jdkrXtjjdd}| j| dS )z>
    Fixture that xfails a test if the engine is pyarrow.
    r@   rP   r   Nr,   pyarrow doesn't support this.)reason)fixturenamesgetfixturevaluer   r>   rL   ZxfailnodeZ
add_marker)r?   r.   rL   r   r   r   pyarrow_xfail  s    


r~   c                 C  sL   d| j kr| d}nd| j kr0| dd }ndS |jdkrHtd dS )z=
    Fixture that skips a test if the engine is pyarrow.
    r@   rP   r   Nr,   ry   )r{   r|   r   r>   skip)r?   r.   r   r   r   pyarrow_skip  s    


r   )3
__future__r   r4   r>   Zpandas.compat._optionalr   Zpandasr   r   Zpandas._testingZ_testingr   r   r"   r&   r(   r)   r+   Zfixturer2   r7   Z_cParserHighMemoryZ_cParserLowMemoryZ_pythonParserZ_pyarrowParserZ_py_parsers_onlyZ_c_parsers_onlyr=   rL   rM   Z_pyarrow_parsers_onlyrI   Z_py_parser_idsZ_c_parser_idsZ_pyarrow_parsers_idsrJ   r@   rC   rD   rE   rO   rP   Z_utf_valuesZ_encoding_sepsrW   Z_encoding_fmtsr\   r]   rx   r~   r   r   r   r   r   <module>   s   (














/

