o
    h                     @   s   d dl Zd dlZd dlm  mZ d dlmZm	Z	 d dl
mZ edejjgZ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)	DataFrameIndexnumba   )paramsc                 C   s   | j S N)param)request r
   q/var/www/html/construction_image-detection-poc/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   sn   t d tdtddgddtddgddd	} d
d }| j|ddd}| j|ddd}tj||ddd d S )Npyarrowr   abzstring[pyarrow_numpy]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)pytestimportorskipr   r   r   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 )Nr4   r
   r   r
   r
   r   r   0       z/test_numba_vs_python_indexing.<locals>.<lambda>r   r   r   r   c                 S   r9   )Nr5   r
   r   r
   r
   r   r   5   r:   r   )r   r   r   r   assert_series_equal)framerow_funcr   r   col_funcr
   r
   r   test_numba_vs_python_indexing+   s   
r?   	reductionc                 C      |   S r   )meanr   r
   r
   r   r   =   r:   r   c                 C   rA   r   )minr   r
   r
   r   r   =   r:   c                 C   rA   r   )maxr   r
   r
   r   r   =   r:   c                 C   rA   r   )sumr   r
   r
   r   r   =   r:   c                 C   sD   t tjdtjd}|j| d|d}|j| d|d}t|| d S )N)r0   r0   r!   r   r   r   )r   nponesfloat64r   r   r;   )r@   r   r*   r   r   r
   r
   r   test_numba_vs_python_reductions;   s   rI   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   	first_colr
   r   r   M   r:   z-test_numba_numeric_colnames.<locals>.<lambda>r   r   r   r   )r   rF   arrayint64r   r   r;   )rJ   r*   fr   r   r
   rN   r   test_numba_numeric_colnamesF   s   "rS   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   T   r   z1test_numba_parallel_unsupported.<locals>.<lambda>zAParallel apply is not supported when raw=False and engine='numba'matchr   parallelT)r   engine_kwargs)r(   raisesNotImplementedErrorr   )r   rR   r
   r
   r   test_numba_parallel_unsupportedS   s   "rZ   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   ]   r   z2test_numba_nonunique_unsupported.<locals>.<lambda>r   r   r-   r8   zBThe index/columns must be unique when raw=False and engine='numba'rT   r   r   )r   r   r(   rX   rY   r   r   rR   r*   r
   r
   r    test_numba_nonunique_unsupported\   s   "r\   c                 C   s   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 s5w   Y  tjtdd |d
  j|d| d W d    d S 1 sYw   Y  d S )Nc                 S   r   r   r
   r   r
   r
   r   r   g   r   z/test_numba_unsupported_dtypes.<locals>.<lambda>r   r-   r   r    r0   r1   r3   r4   zdouble[pyarrow]zAColumn b must have a numeric dtype. Found 'object|string' insteadrT   r   r   zUColumn c is backed by an extension array, which is not supported by the numba engine.)r   astyper(   rX   
ValueErrorr   to_framer[   r
   r
   r   test_numba_unsupported_dtypesf   s   "r`   )numpyrF   r(   pandas.util._test_decoratorsutil_test_decoratorstdpandasr   r   pandas._testing_testingr   
skip_if_nomark
single_cpu
pytestmarkfixturer   r   r+   r?   parametrizerI   rS   rZ   r\   r`   r
   r
   r
   r   <module>   s*    


	
