o
    S+ i                     @   s   d dl Zd dlZd dlmZmZmZmZmZm	Z
mZ d dlmZ ddejdgfddejd	gfd
ejejejgfd
g fddejdgfgZee \ZZejeeddd Zdd Zdd Zejdedgdd Zejdedgdd Zdd ZdS )    N)CategoricalDtype	DataFrameIndex
MultiIndexSeries_testingoption_context)StringMethodsstringacbytes   a   cemptymixed-integer   )paramsidsc                 C   s    | j \}}tj|td}||fS )a<  
    Fixture for all (inferred) dtypes allowed in StringMethods.__init__

    The covered (inferred) types are:
    * 'string'
    * 'empty'
    * 'bytes'
    * 'mixed'
    * 'mixed-integer'

    Returns
    -------
    inferred_dtype : str
        The string for the inferred dtype from _libs.lib.infer_dtype
    values : np.ndarray
        An array of object dtype that will be inferred to have
        `inferred_dtype`

    Examples
    --------
    >>> from pandas._libs import lib
    >>>
    >>> def test_something(any_allowed_skipna_inferred_dtype):
    ...     inferred_dtype, values = any_allowed_skipna_inferred_dtype
    ...     # will pass
    ...     assert lib.infer_dtype(values, skipna=True) == inferred_dtype
    ...
    ...     # constructor for .str-accessor will also pass
    ...     Series(values).str
    dtype)paramnparrayobject)requestinferred_dtypevalues r   i/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/pandas/tests/strings/test_api.py!any_allowed_skipna_inferred_dtype   s   
 r    c                 C   s,   t jtu sJ tt dg| djtsJ d S )N r   )r   strr	   
isinstance)any_string_dtyper   r   r   test_apiA   s   r%   c                  C   sZ   t g dg} d}tjt|d | j W d    n1 sw   Y  t| dr+J d S )N)r   br   z5Can only use .str accessor with Index, not MultiIndexmatchr"   )r   Zfrom_arrayspytestraisesAttributeErrorr"   hasattr)mimsgr   r   r   test_api_mi_raisesG   s   r/   r   categoryc           	      C   s   | }|\}}|||d}g d}||v rt |jtsJ d S d}tjt|d |j W d    n1 s5w   Y  t|drAJ d S )Nr   )r
   unicoder   r   mixedr   z/Can only use .str accessor with string values.*r'   r"   )r#   r"   r	   r)   r*   r+   r,   )	index_or_seriesr   Zany_skipna_inferred_dtypeboxr   r   tZtypes_passing_constructorr.   r   r   r   test_api_per_dtypeP   s   r6   c                 C   s  | }|\}}|\}	}
}d }|t u r=|jdkr=|	dv r%|ddr%t}d}n,|	dkr4|dd r4t}d}n|	dkr<t}d	}n|t u rQ|d
krQ|tkrQ|	dkrQt}d	}|d urbtjj||d}|	| |||d}t
|j|	}|ry|dkry|	dv}nd}|	dv }|	dv}d
gddg|  dg|  ddg|  }||v rtdd ||
i | W d    d S 1 sw   Y  d S d|	 dt| d}tjt|d ||
i | W d    d S 1 sw   Y  d S )Nr   )	partition
rpartitionexpandTz#Method cannot deal with empty Indexsplitz,Split fails on empty Series when expand=TrueZget_dummiesz(Need to fortify get_dummies corner casesr   )r*   reasonr   r0   )decode)r<   getlenslice)catr
   r1   r   r2   r   zfuture.no_silent_downcastingzCannot use .str.z with values of inferred dtype z,.|a bytes-like object is required, not 'str'r'   )r   sizer=   	TypeError
ValueErrorr   r)   markZxfailZapplymarkergetattrr"   r   reprr*   )r3   r   r    any_string_methodr   Zusing_infer_stringr4   r   r   method_nameargskwargsr;   r*   rD   r5   methodZstring_allowedZbytes_allowedZmixed_allowedZallowed_typesr.   r   r   r   test_api_per_methodk   sd   




""rL   c           	      C   s   t td|d}|d | }|d}|t|jjd}t|jts'J | \}}}t	|j||i |}t	|dj||i |}t|t
rRt|| d S t|t r_t|| d S ||kseJ d S )NZaabbr    r0   r   )r   listZastyper   r   
categoriesr#   r"   r	   rE   r   tmZassert_frame_equalZassert_series_equal)	rG   r$   sr   rH   rI   rJ   resultexpectedr   r   r   test_api_for_categorical   s   



rT   )numpyr   r)   Zpandasr   r   r   r   r   r   rP   r   Zpandas.core.strings.accessorr	   nanZ"_any_allowed_skipna_inferred_dtypezipr   _Zfixturer    r%   r/   rD   Zparametrizer   r6   rL   rT   r   r   r   r   <module>   s(    $	
&	

N