U
    9%e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re  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   \/var/www/html/Darija-Ai-API/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>.fooPFall-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>.foo0The '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>.foo2The 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