o
    S+ i^                     @   sP  d dl Zd dlZd dlmZ d dlm  mZ d dl	Z
d dl	mZmZ d dlmZ d dlmZ edejjej gZedZeejjeejedkoQe dej d ejd d	gd
dd Zdd Zdd Zdd Zej ddd dd dd dd gdd Z!ej dg dg dgdd Z"d d! Z#d"d# Z$d$d% Z%dS )&    N)is_platform_arm)	DataFrameIndex)Versionnumbaz0.61z&Segfaults on ARM platforms with numba )reason   )paramsc                 C   s   | j S N)param)request r   i/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/pandas/tests/apply/test_numba.py
apply_axis   s   r   c                 C   s8   dd }| j |d|d}| j |d|d}t|| d S )Nc                 S      | S r
   r   xr   r   r   <lambda>        z+test_numba_vs_python_noop.<locals>.<lambda>r   engineZaxispython)applytmassert_frame_equal)float_framer   funcresultexpectedr   r   r   test_numba_vs_python_noop   s   r   c                  C   sx   t dtddgtjtjddtddgtjtjddd} d	d
 }| j|ddd}| j|ddd}tj||ddd d S )Nr   ab)Zna_valueZdtyper   y)indexcolumnsc                 S   r   r
   r   r   r   r   r   r   -   r   z3test_numba_vs_python_string_index.<locals>.<lambda>r   r   r   r   F)Zcheck_column_typeZcheck_index_type)	r   r   pdZStringDtypenpnanr   r   r   )dfr   r   r   r   r   r   !test_numba_vs_python_string_index&   s   
r*   c                  C   s   t g dg dg ddtg dd} dd }| j|d	d
d}| j|dd
d}t|| dd }| j|d	dd}| j|ddd}t|| d S )Nr                  )g      @g       @g      "@r    r!   c)ABCr$   c                 S      | d S )Nr3   r   r   r   r   r   r   :       z/test_numba_vs_python_indexing.<locals>.<lambda>r   r   r   r   c                 S   r8   )Nr4   r   r   r   r   r   r   ?   r9   r   )r   r   r   r   assert_series_equal)frameZrow_funcr   r   Zcol_funcr   r   r   test_numba_vs_python_indexing5   s   
r<   	reductionc                 C      |   S r
   )meanr   r   r   r   r   G   r9   r   c                 C   r>   r
   )minr   r   r   r   r   G   r9   c                 C   r>   r
   )maxr   r   r   r   r   G   r9   c                 C   r>   r
   )sumr   r   r   r   r   G   r9   c                 C   sD   t tjdtjd}|j| d|d}|j| d|d}t|| d S )N)r/   r/   r"   r   r   r   )r   r'   ZonesZfloat64r   r   r:   )r=   r   r)   r   r   r   r   r   test_numba_vs_python_reductionsE   s   rC   colnamesr+   )g      ?g       @g      @c                    sn   t tjg dg dg dgtjd| d}| d   fdd}|j|d	d
d}|j|dd
d}t|| d S )Nr+   r.   )      	   r"   )r%   r   c                    s   |   S r
   r   r   Z	first_colr   r   r   W   r9   z-test_numba_numeric_colnames.<locals>.<lambda>r   r   r   r   )r   r'   arrayZint64r   r   r:   )rD   r)   fr   r   r   rH   r   test_numba_numeric_colnamesP   s   "rK   c                 C   sP   dd }t jtdd | j|dddid W d    d S 1 s!w   Y  d S )	Nc                 S   r   r
   r   r   r   r   r   r   ^   r   z1test_numba_parallel_unsupported.<locals>.<lambda>zAParallel apply is not supported when raw=False and engine='numba'matchr   ZparallelT)r   Zengine_kwargs)pytestraisesNotImplementedErrorr   )r   rJ   r   r   r   test_numba_parallel_unsupported]   s   "rQ   c                 C   sh   dd }t dddgitddgd}tjtdd |j|d	| d
 W d    d S 1 s-w   Y  d S )Nc                 S   r   r
   r   r   r   r   r   r   g   r   z2test_numba_nonunique_unsupported.<locals>.<lambda>r    r   r,   r7   zBThe index/columns must be unique when raw=False and engine='numba'rL   r   r   )r   r   rN   rO   rP   r   r   rJ   r)   r   r   r    test_numba_nonunique_unsupportedf   s   "rS   c                 C   s   t d dd }tddgddgdd	gd
}|d d|d< t jtdd |j|d| d W d    n1 s:w   Y  t jtdd |d  j|d| d W d    d S 1 s^w   Y  d S )NZpyarrowc                 S   r   r
   r   r   r   r   r   r   r   r   z/test_numba_unsupported_dtypes.<locals>.<lambda>r   r,   r    r!   r/   r0   r2   r3   zdouble[pyarrow]z>Column b must have a numeric dtype. Found 'object|str' insteadrL   r   r   zUColumn c is backed by an extension array, which is not supported by the numba engine.)rN   importorskipr   ZastyperO   
ValueErrorr   Zto_framerR   r   r   r   test_numba_unsupported_dtypesp   s    
"rV   )&numpyr'   rN   Zpandas.compatr   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandasr&   r   r   Zpandas._testingZ_testingr   Zpandas.util.versionr   Z
skip_if_nomarkZ
single_cpuZskipifZ
pytestmarkrT   r   append__version__Zfixturer   r   r*   r<   ZparametrizerC   rK   rQ   rS   rV   r   r   r   r   <module>   s>    




	
