o
    ۾i'                     @   s   d dl Z d dlZd dlmZ d dl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rBe  dS dS )    N)contextmanager)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   Q/home/ubuntu/.local/lib/python3.10/site-packages/numba/tests/test_deprecations.py!_catch_numba_deprecation_warnings   s   "r   c                   @   s   e Zd Zd%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 )&TestDeprecationTc                 C   sZ   |  t|d |  |d j| | |t|d j |r+| dt|d j d S d S )N   r   https://numba.readthedocs.io)assertEquallenr   assertInstrmessage)selfr   expected_strr   	check_rtdr   r   r   check_warning   s   zTestDeprecation.check_warningc                 C   sZ   t   }tdddd }|  d}| j||tdd W d    d S 1 s&w   Y  d S )NFnopythonc                   S      d S Nr   r   r   r   r   foo#   s   z?TestDeprecation.test_explicit_false_nopython_kwarg.<locals>.foo2The keyword argument 'nopython=False' was suppliedr"   )r   r   r#   r   r    r   r(   msgr   r   r   "test_explicit_false_nopython_kwarg   s   
"z2TestDeprecation.test_explicit_false_nopython_kwargc                 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(   3      zOTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reported.<locals>.foor   r   assertFalser    r   r(   r   r   r   2test_vectorize_missing_nopython_kwarg_not_reported,   s
   zBTestDeprecation.test_vectorize_missing_nopython_kwarg_not_reportedc                 C   sT   t  }tddddd }W d    n1 sw   Y  d}| j||tdd d S )Nr.   Fr$   c                 S   r/   r0   r   r1   r   r   r   r(   @   r3   zFTestDeprecation.test_vectorize_nopython_false_is_reported.<locals>.foor)   r*   r   r   r#   r   r+   r   r   r   )test_vectorize_nopython_false_is_reported9   s   
z9TestDeprecation.test_vectorize_nopython_false_is_reportedc                 C   H   t  }tddddd }W d    n1 sw   Y  | | d S )Nr.   Tforceobjc                 S      t   | d S r0   objectr1   r   r   r   r(   M      zRTestDeprecation.test_vectorize_objmode_direct_compilation_no_warnings.<locals>.foor4   r6   r   r   r   5test_vectorize_objmode_direct_compilation_no_warningsG   s
   
zETestDeprecation.test_vectorize_objmode_direct_compilation_no_warningsc                 C   V   t  }tdddddd }W d    n1 sw   Y  d}| j||tdd d S )	Nr.   TF)r<   r%   c                 S   r=   r0   r>   r1   r   r   r   r(   [   r@   zTTestDeprecation.test_vectorize_objmode_compilation_nopython_false_warns.<locals>.foor)   r*   r8   r+   r   r   r   7test_vectorize_objmode_compilation_nopython_false_warnsT   s   zGTestDeprecation.test_vectorize_objmode_compilation_nopython_false_warnsc                 C   r:   )Nr.   paralleltargetc                 S   r/   r0   r   xr   r   r   r(   i   r3   zETestDeprecation.test_vectorize_parallel_true_no_warnings.<locals>.foor4   r6   r   r   r   (test_vectorize_parallel_true_no_warningsc   s
   
z8TestDeprecation.test_vectorize_parallel_true_no_warningsc                 C   J   t  }tdddddd }W d    n1 sw   Y  | | d S )Nr.   rD   TrF   r%   c                 S   r/   r0   r   rG   r   r   r   r(   t   r3   zSTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warnings.<locals>.foor4   r6   r   r   r   6test_vectorize_parallel_true_nopython_true_no_warningso   s
   zFTestDeprecation.test_vectorize_parallel_true_nopython_true_no_warningsc                 C   rB   )	Nr.   rD   FrK   c                 S   r/   r0   r   rG   r   r   r   r(      r3   zNTestDeprecation.test_vectorize_parallel_true_nopython_false_warns.<locals>.foor)   r*   r8   r+   r   r   r   1test_vectorize_parallel_true_nopython_false_warnsz   s   zATestDeprecation.test_vectorize_parallel_true_nopython_false_warnsc                    sT   t  }tddd fdd}dd  W d    n1 sw   Y  | | d S )Nr.   Tr;   c                    s    | d S r0   r   rG   barr   r   r(         zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.fooc                  W   r&   r'   r   )argsr   r   r   rO      s   zZTestDeprecation.test_vectorize_calling_jit_with_nopython_false_warns_from_jit.<locals>.barr4   r6   r   rN   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 r0   r   r2   br   r   r   rO      rP   zKTestDeprecation.test_guvectorize_implicit_nopython_no_warnings.<locals>.barr   r   r5   r    r   rO   r   r   r   .test_guvectorize_implicit_nopython_no_warnings   s
   z>TestDeprecation.test_guvectorize_implicit_nopython_no_warningsc                 C   rJ   )NrS   rT   Tr;   c                 S      t   | d7 } d S r0   r>   rV   r   r   r   rO         zBTestDeprecation.test_guvectorize_forceobj_no_warnings.<locals>.barrX   rY   r   r   r   %test_guvectorize_forceobj_no_warnings   s   z5TestDeprecation.test_guvectorize_forceobj_no_warningsc                 C   rJ   )NrS   rT   rD   rE   c                 S   rU   r0   r   rV   r   r   r   rO      s   zTTestDeprecation.test_guvectorize_parallel_implicit_nopython_no_warnings.<locals>.barrX   rY   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 )NrS   rT   rD   T)rF   r<   c                 S   r[   r0   r>   rV   r   r   r   rO      r\   zKTestDeprecation.test_guvectorize_parallel_forceobj_no_warnings.<locals>.barrX   rY   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 r0   )appendr1   r   r   r   foo_list      
zFTestDeprecation.test_reflection_of_mutable_container.<locals>.foo_listc                 S   r`   r0   )addr1   r   r   r   foo_set   rc   zETestDeprecation.test_reflection_of_mutable_container.<locals>.foo_set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    rb   re   f	containerinpr   warn_msgr,   r   r   r   $test_reflection_of_mutable_container   s,   z4TestDeprecation.test_reflection_of_mutable_containerc                 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_module   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   )CCrp   )r   r   r   r   rq   rt   r#   )r    r   rt   r!   r   r   r   test_pycc_CC   s   "zTestDeprecation.test_pycc_CCN)T)rh   
__module____qualname__r#   r	   run_test_in_subprocessr-   r7   r9   rA   rC   rI   rL   rM   rR   rZ   r]   r^   r_   ro   r
   rs   ru   r   r   r   r   r      sH    















r   __main__)r   unittest
contextlibr   rr   r   r   r   numba.core.errorsr   r   r   numba.tests.supportr	   r
   r   r   rh   mainr   r   r   r   <module>   s    
 s