o
    vh^                     @   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   [/var/www/html/hyperkenya/venv/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   engine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)na_value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)check_column_typecheck_index_type)	r   r   pdStringDtypenpnanr   r   r   )dfr   r   r   r   r   r   !test_numba_vs_python_string_index&   s   
r0   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 )Nr9   r   r   r   r   r   r   :       z/test_numba_vs_python_indexing.<locals>.<lambda>r   r   r   r   c                 S   r>   )Nr:   r   r   r   r   r   r   ?   r?   r   )r   r   r   r   assert_series_equal)framerow_funcr   r   col_funcr   r   r   test_numba_vs_python_indexing5   s   
rD   	reductionc                 C      |   S r
   )meanr   r   r   r   r   G   r?   r   c                 C   rF   r
   )minr   r   r   r   r   G   r?   c                 C   rF   r
   )maxr   r   r   r   r   G   r?   c                 C   rF   r
   )sumr   r   r   r   r   G   r?   c                 C   sD   t tjdtjd}|j| d|d}|j| d|d}t|| d S )N)r5   r5   r$   r   r   r   )r   r-   onesfloat64r   r   r@   )rE   r   r/   r   r   r   r   r   test_numba_vs_python_reductionsE   s   rM   colnamesr1   )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 )Nr1   r4   )      	   r$   )r(   r   c                    s   |   S r
   r   r   	first_colr   r   r   W   r?   z-test_numba_numeric_colnames.<locals>.<lambda>r   r   r   r   )r   r-   arrayint64r   r   r@   )rN   r/   fr   r   r   rR   r   test_numba_numeric_colnamesP   s   "rW   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   parallelT)r   engine_kwargs)pytestraisesNotImplementedErrorr   )r   rV   r   r   r   test_numba_parallel_unsupported]   s   "r_   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   r2   r=   zBThe index/columns must be unique when raw=False and engine='numba'rX   r   r   )r   r   r\   r]   r^   r   r   rV   r/   r   r   r    test_numba_nonunique_unsupportedf   s   "ra   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 )Npyarrowc                 S   r   r
   r   r   r   r   r   r   r   r   z/test_numba_unsupported_dtypes.<locals>.<lambda>r   r2   r!   r"   r5   r6   r8   r9   zdouble[pyarrow]z>Column b must have a numeric dtype. Found 'object|str' insteadrX   r   r   zUColumn c is backed by an extension array, which is not supported by the numba engine.)r\   importorskipr   astyper]   
ValueErrorr   to_framer`   r   r   r   test_numba_unsupported_dtypesp   s    
"rg   )&numpyr-   r\   pandas.compatr   pandas.util._test_decoratorsutil_test_decoratorstdpandasr+   r   r   pandas._testing_testingr   pandas.util.versionr   
skip_if_nomark
single_cpuskipif
pytestmarkrc   r   append__version__fixturer   r    r0   rD   parametrizerM   rW   r_   ra   rg   r   r   r   r   <module>   s>    




	
