o
    \i                      @   s   d dl Z d dlmZ d dlZd dlmZmZmZmZ ej	
dg dddgfg ddgfg dg fgdd	 Zd
d Zej	
deegdd Zej	
deegdd Zej	
dejeej	jdegdd ZdS )    N)BytesIO)_liac_arff_parser_pandas_arff_parser_post_process_frameload_arff_from_gzip_filezfeature_names, target_names)col_int_as_integercol_int_as_numericcol_float_as_realcol_float_as_numericcol_categorical
col_stringc              	   C   s   t d}|g dg dg dg dg dg dd}t|| |\}}t||js-J t|dkr=t||js;J dS t|dkrMt||jsKJ dS |du sSJ dS )	zNCheck the behaviour of the post-processing function for splitting a dataframe.pandas)         )g      ?g       @g      @)abc)r   r   r	   r
   r   r   r   r   N)pytestimportorskip	DataFramer   
isinstancelenSeries)feature_namestarget_namespd
X_originalXy r    /var/www/www-root/data/www/176.119.141.140/sports-predictor/venv/lib/python3.10/site-packages/sklearn/datasets/tests/test_arff_parser.pytest_post_process_frame   s"   
"r"   c                  C   sJ   d} t jt| d tdddddd W d   dS 1 sw   Y  dS )z3An error will be raised if the parser is not known.z8Unknown parser: 'xxx'. Should be 'liac-arff' or 'pandas')matchxxxN)r   raises
ValueErrorr   )err_msgr    r    r!   *test_load_arff_from_gzip_file_error_parserG   s   "r(   parser_funcc           	      C   s   t d}ttdd}dddddddd	dd
ddd}g d}dg}d| tu r0dnd| tu r7dnddd}| |d|||d\}}}}|j || ksTJ |j	
|jd |j|dd dS )z9Check that we properly strip single quotes from the data.r   a5  
            @relation 'toy'
            @attribute 'cat_single_quote' {'A', 'B', 'C'}
            @attribute 'str_single_quote' string
            @attribute 'str_nested_quote' string
            @attribute 'class' numeric
            @data
            'A','some text','"expect double quotes"',0
            utf-8nominalcat_single_quote	data_typenamestringstr_single_quotestr_nested_quotenumericclass)r,   r1   r2   r4   )r,   r1   r2   A	some textz'some text'z"expect double quotes"z'"expect double quotes"'r   output_arrays_typeopenml_columns_infofeature_names_to_selecttarget_names_to_selectr/   N)r   r   r   textwrapdedentencoder   columnstolisttestingassert_series_equalilocr   	r)   r   	arff_filecolumns_infor   r   expected_values_framer    r    r!   +test_pandas_arff_parser_strip_single_quotesQ   sL   

"rK   c           	      C      t d}ttdd}dddddddd	dd
ddd}g d}dg}ddddd}| |d|||d\}}}}|j || ksHJ |j	|j
d |j|dd dS )z9Check that we properly strip double quotes from the data.r   a5  
            @relation 'toy'
            @attribute 'cat_double_quote' {"A", "B", "C"}
            @attribute 'str_double_quote' string
            @attribute 'str_nested_quote' string
            @attribute 'class' numeric
            @data
            "A","some text","'expect double quotes'",0
            r*   r+   cat_double_quoter-   r0   str_double_quoter2   r3   r4   )rM   rN   r2   r4   )rM   rN   r2   r5   r6   z'expect double quotes'r   r7   r<   Nr   r   r   r=   r>   r?   r@   rA   rB   rC   rD   r   rE   r    r    r!   +test_pandas_arff_parser_strip_double_quotes   sH   

"rP   )marksc           	      C   rL   )z7Check that we properly parse with no quotes characters.r   a'  
            @relation 'toy'
            @attribute 'cat_without_quote' {A, B, C}
            @attribute 'str_without_quote' string
            @attribute 'str_internal_quote' string
            @attribute 'class' numeric
            @data
            A,some text,'internal' quote,0
            r*   r+   cat_without_quoter-   r0   str_without_quotestr_internal_quoter3   r4   )rR   rS   rT   r4   )rR   rS   rT   r5   r6   z'internal' quoter   r7   r<   NrO   rE   r    r    r!   'test_pandas_arff_parser_strip_no_quotes   sH   


"rU   )r=   ior   r   sklearn.datasets._arff_parserr   r   r   r   markparametrizer"   r(   rK   rP   paramxfailrU   r    r    r    r!   <module>   s<    


 

F
?