B
     \                 @   s  d Z ddlmZmZmZ ddlZddlZddlm	Z	m
Z
mZmZ ddlmZ ddlmZmZ e	dddd	d
 Zdd Ze	ddddd Ze	ddddd Ze	dddd Ze
ddddd Ze	ddddd Ze	ddddd Ze	ddddd Ze	ddddd Ze	dddd d! Ze	dddd"d# Ze	dddd$d% Ze	dddd&d' ZeZ e	dddd(d' ZeZ!d)d* Z"e"d+Z#e"d,Z$e%d-Z&e	dddd.d/ Z'd0Z(e)d1ej*fd2ej+fgZ,ej)d1ej*fd2ej+fgdd3Z-ej.d4e,d5Z/x4e0e/j1D ]&Z2e2d0 e/e2 d1< e2d6 e/e2 d2< qW ej3e/e-d5Z4e	dddd7d8 Z5G d9d: d:eZ6d;d< Z7e	dddd=d>d? Z8dS )@z
This file will be copied to a temporary directory in order to
exercise caching compiled Numba functions.

See test_dispatcher.py.
    )divisionprint_functionabsolute_importN)jitgenerated_jittypesprange)c_sin)TestCasecaptured_stderrT)cachenopythonc             C   s   | S )N )xr   r   9lib/python3.7/site-packages/numba/tests/cache_usecases.pysimple_usecase   s    r   c             C   s   t | S )N)r   )r   r   r   r   simple_usecase_caller   s    r   c             C   s   | | t  S )N)Z)r   yr   r   r   add_usecase   s    r   )r   Zforceobjc             C   s   t   | | t S )N)objectr   )r   r   r   r   r   add_objmode_usecase    s    r   )r   c             C   s   | | t  S )N)r   )r   r   r   r   r   add_nocache_usecase&   s    r   c             C   s"   t | tjrdd }ndd }|S )Nc             S   s   | | S )Nr   )r   r   r   r   r   impl.   s    zgenerated_usecase.<locals>.implc             S   s   | | S )Nr   )r   r   r   r   r   r   1   s    )
isinstancer   ZComplex)r   r   r   r   r   r   generated_usecase+   s    
r   c             C   s   | | t  S )N)r   )r   r   r   r   r   inner6   s    r   c             C   s   t | | S )N)r   )r   r   r   r   r   outer:   s    r   Fc             C   s   t | | S )N)r   )r   r   r   r   r   outer_uncached>   s    r   c             C   s(   t   d}xt| D ]}|| }qW |S )Nr   )r   range)nZresir   r   r   
loopliftedC   s
    r"   c             C   s   t | S )N)r	   )r   r   r   r   	use_c_sinL   s    r#   c             C   s   t | S )N)r#   )r   r   r   r   use_c_sin_nest1P   s    r$   c             C   s   t | S )N)r$   )r   r   r   r   use_c_sin_nest2T   s    r%   c             C   s   | d S )N   r   )r   r   r   r   ambiguous_functionY   s    r'   c             C   s   | d S )N   r   )r   r   r   r   r'   _   s    c                s   t ddd fdd}|S )NT)r   r   c                s    |  S )Nr   )r   )r   r   r   closureg   s    zmake_closure.<locals>.closure)r   )r   r)   r   )r   r   make_closuref   s    r*         i@B c               C   s   t S )N)biggier   r   r   r   use_big_arrays   s    r.      ab)Zalignr&   )dtypeg     @E@c             C   s   | | S )Nr   )aryr!   r   r   r   record_return   s    r4   c               @   s    e Zd ZdZdd Zdd ZdS )_TestModulez
    Tests for functionality of this module's functions.
    Note this does not define any "test_*" method, instead check_module()
    should be called by hand.
    c             C   s   |  |ddd |  |ddd |  |ddd |  |ddd |  |ddd ||jd}|  t|d ||j	d}|  t|d d S )Nr&   r+   r(   r/   )r&   g     E@)
ZassertPreciseEqualr   r   r   r   r   r4   
packed_arrtuplealigned_arr)selfmodZ
packed_recZaligned_recr   r   r   check_module   s    z_TestModule.check_modulec             C   s   t d S )N)NotImplementedError)r9   r   r   r   runTest   s    z_TestModule.runTestN)__name__
__module____qualname____doc__r;   r=   r   r   r   r   r5      s   r5   c              C   s   t jt } t |  d S )N)sysmodulesr>   r5   r;   )r:   r   r   r   	self_test   s    
rD   )Zparallelr   r   c             C   s   | |  |  S )Nr   )r3   r   r   r   parfor_usecase   s    rE   )9rA   Z
__future__r   r   r   rB   ZnumpyZnpZnumbar   r   r   r   Znumba.tests.ctypes_usecasesr	   Znumba.tests.supportr
   r   r   r   r   r   r   r   r   r   r   r"   r#   r$   r%   r'   Zrenamed_function1Zrenamed_function2r*   Zclosure1Zclosure2Zaranger-   r.   r   r2   Zint8Zfloat64Zpacked_record_typeZaligned_record_typeemptyr6   r   sizer!   Zarrayr8   r4   r5   rD   rE   r   r   r   r   <module>   sP   	
