o
    8ήc	                     @   s$  d Z ddlZddl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)typesc                 C      | | S N abr   r   E/tmp/pip-target-vg8gfxp4/lib/python/numba/tests/serialize_usecases.pyadd_with_sig      r   c                 C   r   r   r   r   r   r   r   add_without_sig   r   r   Tnopythonc                 C   r   r   r   r   r   r   r   add_nopython   r   r   c                 C   s   t   | | S r   )objectr   r   r   r   add_nopython_fail   s   r   c                       t dd fdd}|S )NTr   c                    s    |  | S r   r   )r
   cr	   r   r   inner      zclosure.<locals>.innerr   )r	   r   r   r   r   closure      r   g      @)sqrtc                    s   t di | 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>.innerr   r   )r%   jit_argsr   r   r$   r   closure_with_globals'   s   r'   c                 C   s   t | |S r   r    r!   r%   r"   r   r   r   other_function1   r   r*   )forceobjc                 C   s   t |  S r   )r   r$   r   r   r   get_global_objmode5   r   r,   c                 C   s   t d t| t  fS )N*   )nprandseednpcosrandomr$   r   r   r   get_renamed_module<   s   
r3   c                    r   )NTr   c                    s   t  | | S r   )r*   )r"   zr$   r   r   r   C   s   z-closure_calling_other_function.<locals>.innerr   r%   r   r   r$   r   closure_calling_other_functionB   r   r6   c                    s2   t ddfdd t dd fdd}|S )NTr   c                    s   t  | S r   r(   r"   r$   r   r   other_innerI   r   z2closure_calling_other_closure.<locals>.other_innerc                    s    |  S r   r   r7   r8   r%   r   r   r   M   r   z,closure_calling_other_closure.<locals>.innerr   r5   r   r9   r   closure_calling_other_closureH   s
   r:      r-   c                    s,   d t | tjrdd }|S  fdd}|S )Nr   c                 S   s   | | t  S r   )k1r)   r   r   r   impl\   s   zgenerated_add.<locals>.implc                    s   | | t    S r   )k2r)   k3r   r   r=   _   s   )
isinstancer   Complex)r%   r"   r=   r   r?   r   generated_addX   s   rC   c                  K   s,   d}i }t | | tdi | |d S )Nz
        def dyn_func(x):
            res = 0
            for i in range(x):
                res += x
            return res
        dyn_funcr   )execstripr   )r&   codensr   r   r   _get_dyn_funce   s   rI   ) __doc__r    numbar   r   
numba.corer   int32r   r   r   r   r   r   r   r'   r*   r,   numpyr0   numpy.randomr2   r.   r3   r6   r:   r<   r>   rC   rI   rD   dyn_func_objmoder   r   r   r   <module>   sB    









