o
    ‘i€!  ã                   @   s’   d dl Z d dlZd dlZd dlZ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 d dlmZ G dd„ dejƒZedkrGe ¡  dS dS )	é    N)Újit)ÚNumbaWarningÚ
deprecatedÚNumbaDeprecationWarning)Úerrors)Úignore_internal_warningsc                   @   s\   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚTestBuiltinsc                 C   ó(   d}|   |jt¡ |  |t|jƒ¡ d S )NzbFall-back from the nopython compilation path to the object mode compilation path has been detected©ÚassertEqualÚcategoryr   ÚassertInÚstrÚmessage©ÚselfÚwÚmsg© r   úh/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/tests/test_warnings.pyÚ!check_objmode_deprecation_warning   s   z.TestBuiltins.check_objmode_deprecation_warningc                 C   r	   )Nz0The 'nopython' keyword argument was not suppliedr
   r   r   r   r   Ú$check_nopython_kwarg_missing_warning   s   z1TestBuiltins.check_nopython_kwarg_missing_warningc                 C   sÚ   dd„ }t jddY}t  dt¡ tƒ  t|ƒ}|ddƒ |  t|ƒd¡ |  |d	 ¡ |  |d j	t¡ |  
d
t|d jƒ¡ |  |d j	t¡ |  
dt|d jƒ¡ |  |d ¡ W d   ƒ d S 1 sfw   Y  d S )Nc                 S   s   i }| | S ©Nr   ©ÚxÚyÚar   r   r   Úadd   ó   z1TestBuiltins.test_type_infer_warning.<locals>.addT©ÚrecordÚalwaysé   é   é   r   útype inferencezobject modeé   )ÚwarningsÚcatch_warningsÚsimplefilterr   r   r   r   Úlenr   r   r   r   r   r   ©r   r   r   Úcfuncr   r   r   Útest_type_infer_warning   s   
"ëz$TestBuiltins.test_type_infer_warningc                    sð   t jdt jd‰ ‡ fdd„}tjddZ}t dt¡ tƒ  tdd	|ƒ}|ƒ  |  	t
|ƒd¡ |  |d
 ¡ |  	|d jt¡ |  dt|d jƒ¡ |  	|d jt¡ |  dt|d jƒ¡ |  |d ¡ W d   ƒ d S 1 sqw   Y  d S )Nr$   ©Zdtypec                      ó   ˆ S r   r   r   ©r   r   r   Úreturn_external_array=   ó   zDTestBuiltins.test_return_type_warning.<locals>.return_external_arrayTr   r!   F)Z_nrtr   r"   zreturn typer#   z!object mode without forceobj=Truer&   )ÚnpÚonesÚfloat32r'   r(   r)   r   r   r   r   r*   r   r   r   r   r   r   ©r   r1   r   r,   r   r0   r   Útest_return_type_warning:   s"   ÿ"êz%TestBuiltins.test_return_type_warningc                    s„   t jdt jd‰ ‡ fdd„}tjdd$}t dt¡ tƒ  tdd|ƒ}|ƒ  |  	t
|ƒd	¡ W d
  ƒ d
S 1 s;w   Y  d
S )z9
        Rerun test_return_type_warning with nrt
        r$   r.   c                      r/   r   r   r   r0   r   r   r1   ^   r2   zMTestBuiltins.test_return_type_warning_with_nrt.<locals>.return_external_arrayTr   r!   )Znopythonr   N)r3   r4   r5   r'   r(   r)   r   r   r   r   r*   r6   r   r0   r   Ú!test_return_type_warning_with_nrtX   s   "ùz.TestBuiltins.test_return_type_warning_with_nrtc                 C   sr   dd„ }t jdd%}t  dt¡ tƒ  t|dd}|ddƒ |  t|ƒd	¡ W d   ƒ d S 1 s2w   Y  d S )
Nc                 S   s   g }| | S r   r   r   r   r   r   r   k   r   z7TestBuiltins.test_no_warning_with_forceobj.<locals>.addTr   r!   )Zforceobjr"   r#   r   )r'   r(   r)   r   r   r   r   r*   r+   r   r   r   Útest_no_warning_with_forceobjj   s   
"ùz*TestBuiltins.test_no_warning_with_forceobjc                 C   sj  dd„ }t jdd¡}t  dt¡ tƒ  tjdtjd}t|ƒ}||ƒ d 	d	d
„ |D ƒ¡}| j
t|ƒd|d |  |d ¡ |  
|d jt¡ |  dt|d jƒ¡ |  dt|d jƒ¡ |  
|d jt¡ |  dt|d jƒ¡ |  dt|d jƒ¡ |  
|d jt¡ |  dt|d jƒ¡ |  dt|d jƒ¡ |  |d ¡ W d   ƒ d S 1 s®w   Y  d S )Nc                 S   s,   i }t | jd ƒD ]
}| |  d9  < q	d S )Nr   r#   )ÚrangeÚshape)r   r   Úir   r   r   Údo_loopy   s   ÿz1TestBuiltins.test_loop_lift_warn.<locals>.do_loopTr   r!   r$   r.   Ú
c                 s   s    | ]	}d |j › V  qdS )z----------
N)r   )Ú.0r   r   r   r   Ú	<genexpr>†   s   € z3TestBuiltins.test_loop_lift_warn.<locals>.<genexpr>é   )r   r   r"   r%   zWITH loopliftingr#   zWITHOUT loopliftingr&   z-compiled in object mode without forceobj=Truezbut has lifted loops)r'   r(   r)   r   r   r3   r4   r5   r   Újoinr   r*   r   r   r   r   r   r   )r   r=   r   r   r,   r   r   r   r   Útest_loop_lift_warnx   s.   ÿ"Þz TestBuiltins.test_loop_lift_warnc                 C   s¦   t dƒdd„ ƒ}tjdd;}t d¡ tƒ  |ƒ  |  t|ƒd¡ |  |d jt¡ |  	d	t
|d jƒ¡ |  	dt
|d jƒ¡ W d   ƒ d S 1 sLw   Y  d S )
NÚfooc                   S   s   d S r   r   r   r   r   r   Úbar£   s   z)TestBuiltins.test_deprecated.<locals>.barTr   r!   r"   r   rE   )r   r'   r(   r)   r   r   r*   r   ÚDeprecationWarningr   r   r   )r   rE   r   r   r   r   Útest_deprecated¢   s   

"øzTestBuiltins.test_deprecatedc                 C   s  t  t j¡}| dd¡ t t  d¡¡ t t  d¡¡ tƒ  W d   ƒ n1 s*w   Y  tjddE}t d¡ tƒ  | 	¡  |  
t|ƒd¡ |  
|d jt¡ |  
|d	 jt¡ |  dt|d jƒ¡ |  dt|d	 jƒ¡ W d   ƒ d S 1 s}w   Y  d S )
NrD   é
   ZsameTr   r!   r#   r   r"   )r   ZWarningsFixerr   r(   r'   Úwarnr   r   r)   Úflushr   r*   r   r   r   r   )r   Zwfixr   r   r   r   Útest_warnings_fixer±   s    ý
"ôz TestBuiltins.test_warnings_fixerc           	      C   sŒ   d}d}d}d|||f }t  tjd|g¡}| ¡ \}}|  |j|¡ ttj	ƒ}d|d< t jtjd|g|d}| ¡ \}}|  |j|¡ d S )	Né7   éc   z3'parallel=True' was specified but no transformationa0  if 1:
            import warnings
            from numba.tests.error_usecases import foo
            import numba
            from numba.tests.support import ignore_internal_warnings
            with warnings.catch_warnings(record=True) as w:
                warnings.simplefilter('always')
                ignore_internal_warnings()
                foo()
            for x in w:
                if x.category == numba.errors.NumbaPerformanceWarning:
                    if "%s" in str(x.message):
                        exit(%s)
            exit(%s)
        z-cÚ1Z"NUMBA_DISABLE_PERFORMANCE_WARNINGS)Úenv)
Ú
subprocessÚPopenÚsysÚ
executableÚcommunicater   Ú
returncodeÚdictÚosÚenviron)	r   Znot_found_ret_codeZfound_ret_codeÚexpectedZparallel_codeÚpopenÚoutÚerrrO   r   r   r   Ú!test_disable_performance_warningsÈ   s   ò
z.TestBuiltins.test_disable_performance_warningsN)Ú__name__Ú
__module__Ú__qualname__r   r   r-   r7   r8   r9   rC   rG   rK   r]   r   r   r   r   r      s    *r   Ú__main__)rW   rP   rR   r'   Únumpyr3   ZunittestZnumbar   Znumba.core.errorsr   r   r   Z
numba.corer   Znumba.tests.supportr   ZTestCaser   r^   Úmainr   r   r   r   Ú<module>   s     aÿ