3
Ud                 @   s  d dl Zd dlZd dlmZ d dljjZd dl	m
Z
mZ d dljZd dlmZ ejdddd Zejddd	d
 Zejddejjdejjdddgejjdddgdd Zejddejjdejjdddgejjdddgdd Zejdddd ZdS )    N)NumbaUtilError)	DataFrameoption_context)NUMBA_FUNC_CACHEnumbaz0.46.0c              C   s   dd } t dddddgddddd	gd
ddgd}tjtdd |jdj| dd W d Q R X tjtdd |jdd j| dd W d Q R X d S )Nc             S   s   t | d S )Ng@)sum)x r	   ]/var/www/html/virt/lib64/python3.6/site-packages/pandas/tests/groupby/aggregate/test_numba.pyincorrect_function   s    z;test_correct_function_signature.<locals>.incorrect_functionabg      ?g       @g      @g      @g      @)keydatar   r   )columnszThe first 2)matchr   )engine)r   pytestraisesr   groupbyagg)r   r   r	   r	   r
   test_correct_function_signature   s    r   c              C   s   dd } t dddddgddddd	gd
ddgd}tjtdd |jdj| ddd W d Q R X tjtdd  |jdd j| ddd W d Q R X d S )Nc             [   s   t | d S )Ng@)r   )r   kwargsr	   r	   r
   r      s    z6test_check_nopython_kwargs.<locals>.incorrect_functionr   r   g      ?g       @g      @g      @g      @)r   r   r   r   )r   znumba does not support)r   r      )r   r   )r   r   r   r   r   r   )r   r   r	   r	   r
   test_check_nopython_kwargs   s     r   zignore:\nThe keyword argumentjitTF
pandas_objSeriesr   c             C   s   dd }| rdd l }|j|}tdddddgdddd	d
gdddgd}|||d}|jd}	|dkrn|	d }	|	j|d|d}
|	jdd dd}tj|
| d S )Nc             S   s   t j| d S )Ng@)npmean)valuesindexr	   r	   r
   
func_numba2   s    z(test_numba_vs_cython.<locals>.func_numbar   r   r   g      ?g       @g      @g      @g      @)r   r   r   )r   )nogilparallelnopythonr   r   )r   engine_kwargsc             S   s   t j| d S )Ng@)r   r   )r   r	   r	   r
   <lambda>D   s    z&test_numba_vs_cython.<locals>.<lambda>cython)r   )r   r   r   r   r   tmassert_equal)r   r   r#   r$   r%   r"   r   r   r&   groupedresultexpectedr	   r	   r
   test_numba_vs_cython,   s    
(
r.   c             C   s.  dd }dd }| r0dd l }|j|}|j|}tdddddgdd	d
ddgdddgd}|||d}	|jd}
|dkr|
d }
|
j|d|	d}|
jdd dd}tj|| |dftkst|
j|d|	d}|
jdd dd}tj|| |dftkst|
j|d|	d}|
jdd dd}tj|| d S )Nc             S   s   t j| d S )Ng333333@)r   r   )r    r!   r	   r	   r
   func_1P   s    ztest_cache.<locals>.func_1c             S   s   t j| d S )Ng@)r   r   )r    r!   r	   r	   r
   func_2S   s    ztest_cache.<locals>.func_2r   r   r   g      ?g       @g      @g      @g      @)r   r   r   )r   )r#   r$   r%   r   r   )r   r&   c             S   s   t j| d S )Ng333333@)r   r   )r   r	   r	   r
   r'   e   s    ztest_cache.<locals>.<lambda>r(   )r   Zgroupby_aggc             S   s   t j| d S )Ng@)r   r   )r   r	   r	   r
   r'   l   s    c             S   s   t j| d S )Ng333333@)r   r   )r   r	   r	   r
   r'   r   s    )	r   r   r   r   r   r)   r*   r   AssertionError)r   r   r#   r$   r%   r/   r0   r   r   r&   r+   r,   r-   r	   r	   r
   
test_cacheI   s.    

(
r2   c              C   s~   dd } t dddddgddddd	gd
ddgd}|jd}|j| dd}tdd |j| d d}W d Q R X tj|| d S )Nc             S   s   t j| d S )Ng333333@)r   r   )r    r!   r	   r	   r
   r/   x   s    z&test_use_global_config.<locals>.func_1r   r   g      ?g       @g      @g      @g      @)r   r   r   r   )r   r   )r   zcompute.use_numbaT)r   r   r   r   r)   Zassert_frame_equal)r/   r   r+   r-   r,   r	   r	   r
   test_use_global_configv   s    (
r3   )Znumpyr   r   Zpandas.errorsr   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandasr   r   Zpandas._testingZ_testingr)   Zpandas.core.util.numba_r   Z
skip_if_nor   r   markfilterwarningsZparametrizer.   r2   r3   r	   r	   r	   r
   <module>   s"   


 

 )