B
      \	  ใ               @   s(  d Z ddlZddlmZmZmZ ddlmZ eejejfdd Z	edd Z
ed	d
dd Zed	d
dd Zdd ZdZddlmZ dd Zed	d
dd Zed	ddd ZddlZddlmZ ed	d
dd Zdd Zdd Zd Zd!Zed	d
d"d# Zd$d% Zed	d
Zed	dZ dS )&z_
Separate module with function samples for serialization tests,
to avoid issues with __main__.
้    N)ฺjitฺgenerated_jitฺtypes)ฺexec_c             C   s   | | S )Nฉ )ฺaฺbr   r   ๚=lib/python3.7/site-packages/numba/tests/serialize_usecases.pyฺadd_with_sig   s    r
   c             C   s   | | S )Nr   )r   r   r   r   r	   ฺadd_without_sig   s    r   T)ฺnopythonc             C   s   | | S )Nr   )r   r   r   r   r	   ฺadd_nopython   s    r   c             C   s   t   | | S )N)ฺobject)r   r   r   r   r	   ฺadd_nopython_fail   s    r   c                s   t dd fdd}|S )NT)r   c                s    |  | S )Nr   )r   ฺc)r   r   r	   ฺinner   s    zclosure.<locals>.inner)r   )r   r   r   )r   r	   ฺclosure   s    r   g      @)ฺsqrtc                s   t f | fdd}|S )Nc                s"   t ttd }t  | กt| S )N้   )ฺmaxฺKฺmathฺhypotr   )ฺyฺk)ฺxr   r	   r   (   s    z#closure_with_globals.<locals>.inner)r   )r   ฺjit_argsr   r   )r   r	   ฺclosure_with_globals'   s    r   c             C   s   t  | |กS )N)r   r   )r   r   r   r   r	   ฺother_function1   s    r   )Zforceobjc             C   s   t |  S )N)r   )r   r   r   r	   ฺget_global_objmode5   s    r   c             C   s   t  dก t | กt  ก fS )N้*   )ฺnprandZseedฺnpZcosฺrandom)r   r   r   r	   ฺget_renamed_module<   s    
r$   c                s   t dd fdd}|S )NT)r   c                s   t  | | S )N)r   )r   ฺz)r   r   r	   r   C   s    z-closure_calling_other_function.<locals>.inner)r   )r   r   r   )r   r	   ฺclosure_calling_other_functionB   s    r&   c                s2   t ddfdd t dd fdd}|S )NT)r   c                s   t   | กS )N)r   r   )r   )r   r   r	   ฺother_innerI   s    z2closure_calling_other_closure.<locals>.other_innerc                s    |  S )Nr   )r   )r'   r   r   r	   r   M   s    z,closure_calling_other_closure.<locals>.inner)r   )r   r   r   )r'   r   r	   ฺclosure_calling_other_closureH   s    r(   ้   r    c                s*   d t | tjrdd }n fdd}|S )Nr   c             S   s   | | t  S )N)ฺk1)r   r   r   r   r	   ฺimpl\   s    zgenerated_add.<locals>.implc                s   | | t    S )N)ฺk2)r   r   )ฺk3r   r	   r+   _   s    )ฺ
isinstancer   ZComplex)r   r   r+   r   )r-   r	   ฺgenerated_addX   s
    
r/   c              K   s(   d}i }t | ก | tf | |d S )Nz
        def dyn_func(x):
            res = 0
            for i in range(x):
                res += x
            return res
        ฺdyn_func)r   ฺstripr   )r   ฺcodeฺnsr   r   r	   ฺ_get_dyn_funce   s    r4   )!ฺ__doc__r   Znumbar   r   r   Z	numba.sixr   Zint32r
   r   r   r   r   r   r   r   r   r   Znumpyr"   Znumpy.randomr#   r!   r$   r&   r(   r*   r,   r/   r4   r0   Zdyn_func_objmoder   r   r   r	   ฺ<module>   s0   

