o
    i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rDe  dS dS )    N)contextmanager)jitgenerated_jit	vectorizeguvectorize)NumbaDeprecationWarningNumbaPendingDeprecationWarningNumbaWarning)TestCaseneeds_setuptoolsc                  c   sV    t jdd} t jdtd t jdtd | V  W d    d S 1 s$w   Y  d S )NTrecordignorecategoryalways)warningscatch_warningssimplefilterr	   r   )w r   l/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/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   s`   t  #}tjddtd dd }t|  d}| ||t W d    d S 1 s)w   Y  d S )Nr   z4.*The 'nopython' keyword argument was not supplied.*)r    r   c                   S   s   g S Nr   r   r   r   r   foo&      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   sP   t  }tdd }|  d}| ||t W d    d S 1 s!w   Y  d S )Nc                   S      d S r$   r   r   r   r   r   r%   5      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   sV   t  }tdddd }|  d}| ||t W d    d S 1 s$w   Y  d S )NFnopythonc                   S   r,   r$   r   r   r   r   r   r%   E   r-   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   sL   t  }tdddd }|  W d    n1 sw   Y  | | d S )NTforceobjc                   S   s
   t   d S r$   objectr   r   r   r   r%   U      
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   sD   t  }tddd }W d    n1 sw   Y  | | d S )Nfloat64(float64)c                 S      | d S Nr   r   ar   r   r   r%   e      zOTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reported.<locals>.foor   r   r:   r;   r   r   r   2test_vectorize_missing_nopython_kwarg_not_reported^   s
   zBTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reportedc                 C   sP   t  }tddddd }W d    n1 sw   Y  d}| ||t d S )Nr=   Fr1   c                 S   r>   r?   r   r@   r   r   r   r%   r   rB   zFTestDeprecation.test_vectorize_nopython_false_is_reported.<locals>.foor3   r   r   r#   r   r)   r   r   r   )test_vectorize_nopython_false_is_reportedk   s   
z9TestDeprecation.test_vectorize_nopython_false_is_reportedc                 C   sL   t  }tddd }W d    n1 sw   Y  d}| ||t d S )Nr=   c                 S      t   | d S r?   r7   r@   r   r   r   r%         zWTestDeprecation.test_vectorize_objmode_missing_nopython_kwarg_not_reported.<locals>.foor'   rE   r)   r   r   r   :test_vectorize_objmode_missing_nopython_kwarg_not_reportedy   s   zJTestDeprecation.test_vectorize_objmode_missing_nopython_kwarg_not_reportedc                 C   s~   t  }tddddd }W d    n1 sw   Y  | t|d d}| |d g|t d	}| |d
 g|t d S )Nr=   Fr1   c                 S   rG   r?   r7   r@   r   r   r   r%      rH   zNTestDeprecation.test_vectorize_objmode_nopython_false_is_reported.<locals>.foo   r3   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   H   t  }tddddd }W d    n1 sw   Y  | | d S )Nr=   Tr5   c                 S   rG   r?   r7   r@   r   r   r   r%      rH   zRTestDeprecation.test_vectorize_objmode_direct_compilation_no_warnings.<locals>.foorC   r;   r   r   r   5test_vectorize_objmode_direct_compilation_no_warnings   s
   
zETestDeprecation.test_vectorize_objmode_direct_compilation_no_warningsc                 C   J   t  }tdddddd }W d    n1 sw   Y  | | d S )Nr=   TF)r6   r2   c                 S   rG   r?   r7   r@   r   r   r   r%      rH   zZTestDeprecation.test_vectorize_objmode_compilation_nopython_false_no_warnings.<locals>.foorC   r;   r   r   r   =test_vectorize_objmode_compilation_nopython_false_no_warnings   s
   zMTestDeprecation.test_vectorize_objmode_compilation_nopython_false_no_warningsc                 C   rL   )Nr=   paralleltargetc                 S   r>   r?   r   xr   r   r   r%      rB   zETestDeprecation.test_vectorize_parallel_true_no_warnings.<locals>.foorC   r;   r   r   r   (test_vectorize_parallel_true_no_warnings   s
   
z8TestDeprecation.test_vectorize_parallel_true_no_warningsc                 C   rN   )Nr=   rP   TrR   r2   c                 S   r>   r?   r   rS   r   r   r   r%      rB   zSTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warnings.<locals>.foorC   r;   r   r   r   6test_vectorize_parallel_true_nopython_true_no_warnings   s
   zFTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warningsc                 C   sR   t  }tdddddd }W d    n1 sw   Y  d}| ||t d S )Nr=   rP   FrV   c                 S   r>   r?   r   rS   r   r   r   r%      rB   zNTestDeprecation.test_vectorize_parallel_true_nopython_false_warns.<locals>.foor3   rE   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 d    n1 sw   Y  | | t  }tddd fdd}td	d  W d    n1 sHw   Y  d
}| ||t d S )Nr=   Tr5   c                        | d S r?   r   rS   barr   r   r%         zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.fooc                  W   r,   r$   r   )argsr   r   r   r[      r&   zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.barc                    rY   r?   r   rS   rZ   r   r   r%      r\   c                 S   s   | S r$   r   rS   r   r   r   r[      r-   r.   )r   r   r:   r   r#   r   r)   r   rZ   r   =test_vectorize_calling_jit_with_nopython_false_warns_from_jit   s   



	zMTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jitc                 C   sF   t  }tdddd }W d    n1 sw   Y  | | d S )N void(float64[::1], float64[::1])(n)->(n)c                 S      | d7 } d S r?   r   rA   br   r   r   r[     r\   zKTestDeprecation.test_guvectorize_implicit_nopython_no_warnings.<locals>.barr   r   r:   r!   r   r[   r   r   r   .test_guvectorize_implicit_nopython_no_warnings  s
   z>TestDeprecation.test_guvectorize_implicit_nopython_no_warningsc                 C   rN   )Nr_   r`   Tr5   c                 S      t   | d7 } d S r?   r7   rb   r   r   r   r[        zBTestDeprecation.test_guvectorize_forceobj_no_warnings.<locals>.barrd   re   r   r   r   %test_guvectorize_forceobj_no_warnings  s   z5TestDeprecation.test_guvectorize_forceobj_no_warningsc                 C   rN   )Nr_   r`   rP   rQ   c                 S   ra   r?   r   rb   r   r   r   r[   !  s   zTTestDeprecation.test_guvectorize_parallel_implicit_nopython_no_warnings.<locals>.barrd   re   r   r   r   7test_guvectorize_parallel_implicit_nopython_no_warnings  s   zGTestDeprecation.test_guvectorize_parallel_implicit_nopython_no_warningsc                 C   sL   t  }tddddddd }W d    n1 sw   Y  | | d S )Nr_   r`   rP   T)rR   r6   c                 S   rg   r?   r7   rb   r   r   r   r[   0  rh   zKTestDeprecation.test_guvectorize_parallel_forceobj_no_warnings.<locals>.barrd   re   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 ]l}|j d}t|dg}tjddO}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 d    n1 ssw   Y  qd S )Nc                 S   
   |  dS r?   )appendr@   r   r   r   foo_list;     
zFTestDeprecation.test_reflection_of_mutable_container.<locals>.foo_listc                 S   rl   r?   )addr@   r   r   r   foo_set>  ro   zETestDeprecation.test_reflection_of_mutable_container.<locals>.foo_setZfoo_
   Tr   r   r   r   r1   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!   rn   rq   f	containerinpr   Zwarn_msgr*   r   r   r   $test_reflection_of_mutable_container8  s,   z4TestDeprecation.test_reflection_of_mutable_containerc                    sb   t  $}tdd  tdd fdd}|  | |dt W d    d S 1 s*w   Y  d S )Nc                   S   s   dd S )Nc                   S   r,   r$   r   r   r   r   r   <lambda>Z  s    zATestDeprecation.test_generated_jit.<locals>.bar.<locals>.<lambda>r   r   r   r   r   r[   X  rB   z/TestDeprecation.test_generated_jit.<locals>.barTr1   c                      s
      d S r$   r   r   rZ   r   r   r%   \  r9   z/TestDeprecation.test_generated_jit.<locals>.fooz!numba.generated_jit is deprecated)r   r   r   r#   r   r;   r   rZ   r   test_generated_jitS  s   
"z"TestDeprecation.test_generated_jitc                 C   sZ   t jdd}t jdtd dd l}d}| ||t W d    d S 1 s&w   Y  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   s^   t jdd}t jdtd ddlm} d}| ||t W d    d S 1 s(w   Y  d S )NTr   r   r   r   )CCr|   )r   r   r   r   r}   r   r#   )r!   r   r   r"   r   r   r   test_pycc_CCr  s   "zTestDeprecation.test_pycc_CCN)rs   
__module____qualname__r#   r
   Zrun_test_in_subprocessr+   r0   r4   r<   rD   rF   rI   rK   rM   rO   rU   rW   rX   r^   rf   ri   rj   rk   ry   r{   r   r   r   r   r   r   r   r      s`    













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