
    J/Ph                         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	Z	d dl
mZmZ d dlmZ ej        d             Z G d dee	j                  ZdS )    N)StringIO)SerialMixincreate_temp_module)
dispatcherc              #      K   	 t                      }t          j        |          }|                     |           |V  |                     |           d S # |                     |           w xY wN)r   loggingStreamHandler
addHandlerremoveHandler)lbufferhandlers      [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/tests/test_jit_module.pycaptured_logsr      so      !'//	W	         s   ;A A-c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestJitModulez
from numba import jit_module

def inc(x):
    return x + 1

def add(x, y):
    return x + y

def inc_add(x):
    y = inc(x)
    return add(x, y)

import numpy as np
mean = np.mean

class Foo(object):
    pass

jit_module({jit_options})
c                 r   t          t          j                  }t          t          j                  }t          | j                  5 }t          j                            |j	                  }| 
                    |t          j        d                    | 
                    t          j        dd          |           |                     |j        t          j        v            d d d            n# 1 swxY w Y   | 
                    t          j        |           | 
                    t          j        |           d S )Nr      )listsyspathdictmodulesr   source_linesosdirname__file__assertEqual
assertTrue__name__)selfsys_path_originalsys_modules_originaltest_moduletemp_module_dirs        r   test_create_temp_jitted_modulez,TestJitModule.test_create_temp_jitted_module1   s<    NN#CK00 122 	Ak gook.BCCO_chqk:::SXabb\+<===OOK0CK?@@@		A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	#4555&:;;;;;s   BC,,C03C0c                 l   	 t          t          j                  }t          t          j                  }t          | j                  5  t          d          # 1 swxY w Y   d S # t          $ rD |                     t          j        |           |                     t          j        |           Y d S w xY w)NzSomething went wrong!)	r   r   r   r   r   r   r   
ValueErrorr   )r"   r#   r$   s      r   -test_create_temp_jitted_module_with_exceptionz;TestJitModule.test_create_temp_jitted_module_with_exception=   s    	@ $SX#'#4#4 #D$566 : : !8999: : : : : : : : : : 	@ 	@ 	@SX'8999S[*>??????	@s1   AA% AAA% A A% %A
B32B3c                 v   t          | j                  5 }|                     |j        t          j                   |                     |j        t          j                   |                     |j        t          j                   |                     |j	        t          j	        u            |                     t          j        |j                             d\  }}|                     |                    |          |j                            |                     |                     |                    ||          |j                            ||                     |                     |                    |          |j                            |                     d d d            d S # 1 swxY w Y   d S )N)g333333?gffffff@)r   r   assertIsInstanceincr   
Dispatcheraddinc_addr    meannpinspectisclassFoor   py_func)r"   r%   xys       r   test_jit_modulezTestJitModule.test_jit_moduleH   s    122 	=k!!+/:3HIII!!+/:3HIII!!+"5z7LMMMOOK,7888OOGOKO<<=== DAq[__Q//(_44Q779 9 9[__Q22(_44Q::< < <[0033(088;;= = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   FF..F25F2c                     ddddd}t          | j        fi |5 }|                     |j        j        |           d d d            d S # 1 swxY w Y   d S )NTFnumpy)nopythonnogilerror_modelboundscheck)r   r   r   r-   targetoptions)r"   jit_optionsr%   s      r   test_jit_module_jit_optionsz)TestJitModule.test_jit_module_jit_optionsY   s    #' %&-&+ 
   1 / /"-/ / 	I2=[_:KHHH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	Is   !AAAc           	          d}dddd}t          dd|i|5 }|                     |j        j        |           |                     |j        j        ddd dd           d d d            d S # 1 swxY w Y   d S )	Nz
from numba import jit, jit_module

@jit(nogil=True, forceobj=True)
def inc(x):
    return x + 1

def add(x, y):
    return x + y

jit_module({jit_options})
Tr;   F)r<   r>   r?   r   )r=   forceobjr?   r<    )r   r   r/   r@   r-   )r"   r   rA   r%   s       r   $test_jit_module_jit_options_overridez2TestJitModule.test_jit_module_jit_options_overridec   s    $(&-&+    / /\ /"-/ / 	G2=[_:KHHH [_:'+-1uF FG G G	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   AA**A.1A.c                     t          j        d          }|                    t           j                   ddd}t	          |          5 t          | j        fi |5 }                                dd                    |j	                  d                    |          g}| 
                    t          fd|D                                  d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )	Nnumba.core.decoratorsTr;   )r<   r>   zAuto decorating functionzfrom module {}zwith jit and options: {}c              3       K   | ]}|v V  	d S r   rE   ).0ilogss     r   	<genexpr>z?TestJitModule.test_jit_module_logging_output.<locals>.<genexpr>   s'      #@#@!AI#@#@#@#@#@#@    )r	   	getLoggersetLevelDEBUGr   r   r   getvalueformatr!   r    all)r"   loggerrA   r%   expectedrL   s        @r   test_jit_module_logging_outputz,TestJitModule.test_jit_module_logging_output}   s   "#:;;&&&#'&-  6"" 	Bd#D$5 3 3&13 3 B6A}}6,33K4HII6==kJJL #@#@#@#@x#@#@#@ @ @AAAB B B B B B B B B B B B B B B	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs7   	C3A3CC3C	C3"C	#C33C7:C7c                 d   t          j        d          }|                    t           j                   t	          |          5 }t          | j                  5  |                     |                                d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NrH    )	r	   rO   rP   INFOr   r   r   r   rR   )r"   rU   rL   s      r   test_jit_module_logging_levelz+TestJitModule.test_jit_module_logging_level   s   "#:;;%%%6"" 	6d#D$566 6 6  "5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s6   B%)BB%B	B%B	B%%B),B)N)r!   
__module____qualname__r   r'   r*   r9   rB   rF   rW   r[   rE   rN   r   r   r      s        L,
< 
< 
<	@ 	@ 	@= = ="I I IG G G4B B B6 6 6 6 6rN   r   )r   r   r3   
contextlibr;   r2   r	   ior   unittestnumba.tests.supportr   r   
numba.corer   contextmanagerr   TestCaser   rE   rN   r   <module>re      s    				 



                  ? ? ? ? ? ? ? ? ! ! ! ! ! ! ! ! !y6 y6 y6 y6 y6K!2 y6 y6 y6 y6 y6rN   