U
    iâËd9  ã                   @   sˆ   d dl Z d dlZd dlmZ d dlmZmZmZmZ d dl	m
Z
mZmZ d dlmZmZ edd„ ƒZG dd	„ d	eƒZed
kr„e ¡  dS )é    N)Úcontextmanager)ÚjitÚgenerated_jitÚ	vectorizeÚguvectorize)ÚNumbaDeprecationWarningÚNumbaPendingDeprecationWarningÚNumbaWarning)ÚTestCaseÚneeds_setuptoolsc               	   c   s>   t jdd��(} t jdtd� t jdtd� | V  W 5 Q R X d S )NT©ÚrecordÚignore©ÚcategoryÚalways)ÚwarningsÚcatch_warningsÚsimplefilterr	   r   )Úw© r   úV/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numba/tests/test_deprecations.pyÚ!_catch_numba_deprecation_warnings   s    r   c                   @   sP  e Zd Zdd„ Zejdd„ ƒZejdd„ ƒZejdd„ ƒZejd	d
„ ƒZ	ejdd„ ƒZ
ejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd „ ƒZejd!d"„ ƒZejd#d$„ ƒZejd%d&„ ƒZejd'd(„ ƒZejd)d*„ ƒZeejd+d,„ ƒƒZeejd-d.„ ƒƒZd/S )0ÚTestDeprecationc                 C   sR   |   t|ƒd¡ |   |d j|¡ |  |t|d jƒ¡ |  dt|d jƒ¡ d S )Né   r   úhttps://numba.readthedocs.io)ÚassertEqualÚlenr   ÚassertInÚstrÚmessage)Úselfr   Úexpected_strr   r   r   r   Úcheck_warning   s    zTestDeprecation.check_warningc              	   C   sJ   t ƒ �:}tjddtd� dd„ }t|ƒƒ  d}|  ||t¡ W 5 Q R X d S )Nr   z4.*The 'nopython' keyword argument was not supplied.*)r    r   c                   S   s   g S ©Nr   r   r   r   r   Úfoo&   s    z-TestDeprecation.test_jitfallback.<locals>.fooúPFall-back from the nopython compilation path to the object mode compilation path)r   r   Úfilterwarningsr   r   r#   ©r!   r   r%   Úmsgr   r   r   Útest_jitfallback   s    ý
z TestDeprecation.test_jitfallbackc              	   C   s:   t ƒ �*}tdd„ ƒ}|ƒ  d}|  ||t¡ W 5 Q R X d S )Nc                   S   s   d S r$   r   r   r   r   r   r%   5   s    z@TestDeprecation.test_default_missing_nopython_kwarg.<locals>.fooú0The 'nopython' keyword argument was not supplied©r   r   r#   r   r(   r   r   r   Ú#test_default_missing_nopython_kwarg/   s    
z3TestDeprecation.test_default_missing_nopython_kwargc              	   C   s@   t ƒ �0}tdd�dd„ ƒ}|ƒ  d}|  ||t¡ W 5 Q R X d S )NF©Únopythonc                   S   s   d S r$   r   r   r   r   r   r%   E   s    z?TestDeprecation.test_explicit_false_nopython_kwarg.<locals>.fooú2The keyword argument 'nopython=False' was suppliedr,   r(   r   r   r   Ú"test_explicit_false_nopython_kwarg>   s    
z2TestDeprecation.test_explicit_false_nopython_kwargc              	   C   s8   t ƒ �}tdd�dd„ ƒ}|ƒ  W 5 Q R X |  |¡ d S )NT©Úforceobjc                   S   s
   t ƒ  d S r$   ©Úobjectr   r   r   r   r%   U   s    zSTestDeprecation.test_default_missing_nopython_kwarg_silent_if_forceobj.<locals>.foo)r   r   ÚassertFalse©r!   r   r%   r   r   r   Ú6test_default_missing_nopython_kwarg_silent_if_forceobjN   s
    
zFTestDeprecation.test_default_missing_nopython_kwarg_silent_if_forceobjc              	   C   s0   t ƒ �}tdƒdd„ ƒ}W 5 Q R X |  |¡ d S )Núfloat64(float64)c                 S   s   | d S ©Nr   r   ©Úar   r   r   r%   e   s    zOTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reported.<locals>.foo©r   r   r6   r7   r   r   r   Ú2test_vectorize_missing_nopython_kwarg_not_reported^   s    zBTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reportedc              	   C   s<   t ƒ �}tddd�dd„ ƒ}W 5 Q R X d}|  ||t¡ d S )Nr9   Fr.   c                 S   s   | d S r:   r   r;   r   r   r   r%   r   s    zFTestDeprecation.test_vectorize_nopython_false_is_reported.<locals>.foor0   ©r   r   r#   r   r(   r   r   r   Ú)test_vectorize_nopython_false_is_reportedk   s
    
z9TestDeprecation.test_vectorize_nopython_false_is_reportedc              	   C   s8   t ƒ �}tdƒdd„ ƒ}W 5 Q R X d}|  ||t¡ d S )Nr9   c                 S   s   t ƒ  | d S r:   r4   r;   r   r   r   r%   �   s    zWTestDeprecation.test_vectorize_objmode_missing_nopython_kwarg_not_reported.<locals>.foor&   r?   r(   r   r   r   Ú:test_vectorize_objmode_missing_nopython_kwarg_not_reportedy   s
    zJTestDeprecation.test_vectorize_objmode_missing_nopython_kwarg_not_reportedc              	   C   sj   t ƒ �}tddd�dd„ ƒ}W 5 Q R X |  t|ƒd¡ d}|  |d g|t¡ d	}|  |d
 g|t¡ d S )Nr9   Fr.   c                 S   s   t ƒ  | d S r:   r4   r;   r   r   r   r%   ”   s    zNTestDeprecation.test_vectorize_objmode_nopython_false_is_reported.<locals>.fooé   r0   r   r&   r   )r   r   r   r   r#   r   r(   r   r   r   Ú1test_vectorize_objmode_nopython_false_is_reportedŠ   s    
zATestDeprecation.test_vectorize_objmode_nopython_false_is_reportedc              	   C   s4   t ƒ �}tddd�dd„ ƒ}W 5 Q R X |  |¡ d S )Nr9   Tr2   c                 S   s   t ƒ  | d S r:   r4   r;   r   r   r   r%   ©   s    zRTestDeprecation.test_vectorize_objmode_direct_compilation_no_warnings.<locals>.foor=   r7   r   r   r   Ú5test_vectorize_objmode_direct_compilation_no_warnings£   s    
zETestDeprecation.test_vectorize_objmode_direct_compilation_no_warningsc              	   C   s6   t ƒ �}tdddd�dd„ ƒ}W 5 Q R X |  |¡ d S )Nr9   TF)r3   r/   c                 S   s   t ƒ  | d S r:   r4   r;   r   r   r   r%   ·   s    zZTestDeprecation.test_vectorize_objmode_compilation_nopython_false_no_warnings.<locals>.foor=   r7   r   r   r   Ú=test_vectorize_objmode_compilation_nopython_false_no_warnings°   s    zMTestDeprecation.test_vectorize_objmode_compilation_nopython_false_no_warningsc              	   C   s4   t ƒ �}tddd�dd„ ƒ}W 5 Q R X |  |¡ d S )Nr9   Úparallel©Útargetc                 S   s   | d S r:   r   ©Úxr   r   r   r%   Ä   s    zETestDeprecation.test_vectorize_parallel_true_no_warnings.<locals>.foor=   r7   r   r   r   Ú(test_vectorize_parallel_true_no_warnings¾   s    
z8TestDeprecation.test_vectorize_parallel_true_no_warningsc              	   C   s6   t ƒ �}tdddd�dd„ ƒ}W 5 Q R X |  |¡ d S )Nr9   rF   T©rH   r/   c                 S   s   | d S r:   r   rI   r   r   r   r%   Ï   s    zSTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warnings.<locals>.foor=   r7   r   r   r   Ú6test_vectorize_parallel_true_nopython_true_no_warningsÊ   s    zFTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warningsc              	   C   s>   t ƒ �}tdddd�dd„ ƒ}W 5 Q R X d}|  ||t¡ d S )Nr9   rF   FrL   c                 S   s   | d S r:   r   rI   r   r   r   r%   Ú   s    zNTestDeprecation.test_vectorize_parallel_true_nopython_false_warns.<locals>.foor0   r?   r(   r   r   r   Ú1test_vectorize_parallel_true_nopython_false_warnsÕ   s
    zATestDeprecation.test_vectorize_parallel_true_nopython_false_warnsc              	      sˆ   t ƒ �&}tddd�‡ fdd„ƒ}dd„ ‰ W 5 Q R X |  |¡ t ƒ �*}tddd�‡ fdd„ƒ}td	d„ ƒ‰ W 5 Q R X d
}|  ||t¡ d S )Nr9   Tr2   c                    s   ˆ | d ƒS r:   r   rI   ©Úbarr   r   r%   ê   s    zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.fooc                  W   s   d S r$   r   )Úargsr   r   r   rP   î   s    zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.barc                    s   ˆ | d ƒS r:   r   rI   rO   r   r   r%   ö   s    c                 S   s   | S r$   r   rI   r   r   r   rP   ú   s    r+   )r   r   r6   r   r#   r   r(   r   rO   r   Ú=test_vectorize_calling_jit_with_nopython_false_warns_from_jitá   s    


zMTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jitc              	   C   s2   t ƒ �}tddƒdd„ ƒ}W 5 Q R X |  |¡ d S )Nú void(float64[::1], float64[::1])ú(n)->(n)c                 S   s   | d7 } d S r:   r   ©r<   Úbr   r   r   rP     s    zKTestDeprecation.test_guvectorize_implicit_nopython_no_warnings.<locals>.bar©r   r   r6   ©r!   r   rP   r   r   r   Ú.test_guvectorize_implicit_nopython_no_warnings  s    z>TestDeprecation.test_guvectorize_implicit_nopython_no_warningsc              	   C   s6   t ƒ �}tdddd�dd„ ƒ}W 5 Q R X |  |¡ d S )NrS   rT   Tr2   c                 S   s   t ƒ  | d7 } d S r:   r4   rU   r   r   r   rP     s    zBTestDeprecation.test_guvectorize_forceobj_no_warnings.<locals>.barrW   rX   r   r   r   Ú%test_guvectorize_forceobj_no_warnings  s    ÿz5TestDeprecation.test_guvectorize_forceobj_no_warningsc              	   C   s6   t ƒ �}tdddd�dd„ ƒ}W 5 Q R X |  |¡ d S )NrS   rT   rF   rG   c                 S   s   | d7 } d S r:   r   rU   r   r   r   rP   !  s    zTTestDeprecation.test_guvectorize_parallel_implicit_nopython_no_warnings.<locals>.barrW   rX   r   r   r   Ú7test_guvectorize_parallel_implicit_nopython_no_warnings  s    ÿzGTestDeprecation.test_guvectorize_parallel_implicit_nopython_no_warningsc              	   C   s8   t ƒ �}tddddd�dd„ ƒ}W 5 Q R X |  |¡ d S )NrS   rT   rF   T)rH   r3   c                 S   s   t ƒ  | d7 } d S r:   r4   rU   r   r   r   rP   0  s    zKTestDeprecation.test_guvectorize_parallel_forceobj_no_warnings.<locals>.barrW   rX   r   r   r   Ú.test_guvectorize_parallel_forceobj_no_warnings(  s     ÿz>TestDeprecation.test_guvectorize_parallel_forceobj_no_warningsc           	   
   C   sâ   dd„ }dd„ }||fD ]Ä}|j  d¡}t|ƒdgƒ}tjdd��”}tjd	td
� tjdtd
� tdd�|ƒ|ƒ |  	t
|ƒd¡ |  	|d jt¡ t|d jƒ}d}|  ||¡ d| }|  ||¡ |  d|¡ W 5 Q R X qd S )Nc                 S   s
   |   d¡S r:   )Úappendr;   r   r   r   Úfoo_list;  s    zFTestDeprecation.test_reflection_of_mutable_container.<locals>.foo_listc                 S   s
   |   d¡S r:   )Úaddr;   r   r   r   Úfoo_set>  s    zETestDeprecation.test_reflection_of_mutable_container.<locals>.foo_setZfoo_é
   Tr   r   r   r   r.   r   r   z?Encountered the use of a type that is scheduled for deprecationz!'reflected %s' found for argumentr   )Ú__name__ÚstripÚevalr   r   r   r	   r   r   r   r   r   r   r    r   )	r!   r^   r`   ÚfÚ	containerZinpr   Zwarn_msgr)   r   r   r   Ú$test_reflection_of_mutable_container8  s&    ÿz4TestDeprecation.test_reflection_of_mutable_containerc              	      sL   t ƒ �<}tdd„ ƒ‰ tdd�‡ fdd„ƒ}|ƒ  |  |dt¡ W 5 Q R X d S )Nc                   S   s   dd„ S )Nc                   S   s   d S r$   r   r   r   r   r   Ú<lambda>Z  ó    zATestDeprecation.test_generated_jit.<locals>.bar.<locals>.<lambda>r   r   r   r   r   rP   X  s    z/TestDeprecation.test_generated_jit.<locals>.barTr.   c                      s
   ˆ ƒ  d S r$   r   r   rO   r   r   r%   \  s    z/TestDeprecation.test_generated_jit.<locals>.fooz!numba.generated_jit is deprecated)r   r   r   r#   r   r7   r   rO   r   Útest_generated_jitS  s    
ÿz"TestDeprecation.test_generated_jitc              	   C   sD   t jdd��.}t jdtd� dd l}d}|  ||t¡ W 5 Q R X d S )NTr   r   r   r   ú)The 'pycc' module is pending deprecation.)r   r   r   r   Ú
numba.pyccr#   )r!   r   Únumbar"   r   r   r   Útest_pycc_modulee  s    ÿz TestDeprecation.test_pycc_modulec              	   C   sH   t jdd��2}t jdtd� ddlm} d}|  ||t¡ W 5 Q R X d S )NTr   r   r   r   )ÚCCrk   )r   r   r   r   rl   ro   r#   )r!   r   ro   r"   r   r   r   Útest_pycc_CCr  s    ÿzTestDeprecation.test_pycc_CCN)rb   Ú
__module__Ú__qualname__r#   r
   Zrun_test_in_subprocessr*   r-   r1   r8   r>   r@   rA   rC   rD   rE   rK   rM   rN   rR   rY   rZ   r[   r\   rg   rj   r   rn   rp   r   r   r   r   r      s^   




















r   Ú__main__)r   ZunittestÚ
contextlibr   rm   r   r   r   r   Znumba.core.errorsr   r   r	   Znumba.tests.supportr
   r   r   r   rb   Úmainr   r   r   r   Ú<module>   s   
  o