a
    
dE                     @   s   d dl Z d dlm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 d dlmZmZ d dlmZmZ d dlmZ d dlmZ d d	lmZmZmZ e Zd
d ZG dd deZG dd de jZedkre   dS )    N)TestCase)compile_isolated)jittyped)typesutils)TypingErrorLoweringError)_header_lead)numpy_version)tag_32bitcaptured_stdoutc                 C   s,   dd t | D }d}|D ]}||7 }q|S )Nc                 S   s   g | ]}|qS  r   .0ir   r   g/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/numba/tests/test_comprehension.py
<listcomp>       zcomp_list.<locals>.<listcomp>r   range)nlsr   r   r   r   	comp_list   s
    
r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestListComprehensionc                 C   sX   t }t|tjg}|j}| |d|d | |d|d | |d|d d S )N   r   )r   r   r   intpentry_pointassertEqual)selfpyfunccrescfuncr   r   r   test_comp_list!   s    z$TestListComprehension.test_comp_listc                     s  t ddfdddd }dd }d	d
 }dd }dd }dd }dd }dd }dd }	dd }
dd }dd }dd }dd  }d!d" }d#d$ }d%d& }d'  fd(d)}d'  fd*d+}d,d- }fd.d/}d0d1 }d2d3 }d4d5 }d6d7 }||||||||	|
|||||||||||||||g}g d8}|D ]t}z&t dd|}| |||| W nF ty   ztj|||| W n ty    Y n0 Y n0 q2| t&}t dd|}|| W d9   n1 s0    Y  t	j
d:krd;}nd<}d9S )=z3 Tests the large number of use cases defined below Tnopythonc                    s$   | dk r| S  | d  | d  S )N      r   r   fib3r   r   r-   -   s    z7TestListComprehension.test_bulk_use_cases.<locals>.fib3c                 S   s   dd t dt| d D S )z Test basic list comprehension c                 S   s   g | ]}|qS r   r   r   r   r   r   r   5   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list1.<locals>.<listcomp>r*   )r   lenxr   r   r   list13   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list1c                 S   s   dd | D S )z% Test conditional list comprehension c                 S   s   g | ]}|d k r|qS r)   r   r   yr   r   r   r   9   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list2.<locals>.<listcomp>r   r/   r   r   r   list27   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list2c                 S   s   dd | D S )z! Test ternary list comprehension c                 S   s   g | ]}|d k r|ndqS )r)   r   r   r3   r   r   r   r   =   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list3.<locals>.<listcomp>r   r/   r   r   r   list3;   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list3c                 S   s   t g dS )z* Test list comprehension to np.array ctor r*   r)      nparrayr/   r   r   r   list4?   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list4c                    s   t  fdd D S )z1 Test nested list comprehension to np.array ctor c                    s    g | ]}t d d  D qS )c                 S   s   g | ]}|qS r   r   r   zr   r   r   r   F   r   zWTestListComprehension.test_bulk_use_cases.<locals>.list5.<locals>.<listcomp>.<listcomp>r9   r3   r/   r   r   r   F   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list5.<locals>.<listcomp>r9   r/   r   r/   r   list5D   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list5c                    s   dd   fdd| D S )z2 Test use of inner function in list comprehension c                 S   s   | d S Nr*   r   r/   r   r   r   innerJ   s    zGTestListComprehension.test_bulk_use_cases.<locals>.list6.<locals>.innerc                    s   g | ]} |qS r   r   r=   rA   r   r   r   L   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list6.<locals>.<listcomp>r   r/   r   rB   r   list6H   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list6c                    s"   dfdd  fdd| D S )z+ Test use of closure in list comprehension r8   c                    s   |   S )Nr   r/   )r4   r   r   rA   R   s    zGTestListComprehension.test_bulk_use_cases.<locals>.list7.<locals>.innerc                    s   g | ]} |qS r   r   r=   rB   r   r   r   T   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list7.<locals>.<listcomp>r   r/   r   )rA   r4   r   list7N   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list7c                 S   s"   dd | D }dd }||}|S )z9 Test use of list comprehension as arg to inner function c                 S   s   g | ]}|d  qS r*   r   r=   r   r   r   r   X   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list8.<locals>.<listcomp>c                 S   s   | d d S Nr   r*   r   r/   r   r   r   rA   Z   s    zGTestListComprehension.test_bulk_use_cases.<locals>.list8.<locals>.innerr   )r0   r   rA   qr   r   r   list8V   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list8c                    s"   dd | D   fdd}|| S )z2 Test use of list comprehension access in closure c                 S   s   g | ]}|d  qS rE   r   r=   r   r   r   r   a   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list9.<locals>.<listcomp>c                    s   | d  d  S rF   r   r/   r   r   r   rA   c   s    zGTestListComprehension.test_bulk_use_cases.<locals>.list9.<locals>.innerr   r0   rA   r   rI   r   list9_   s    z8TestListComprehension.test_bulk_use_cases.<locals>.list9c                    s"   dd | D   fdd}| S )z= Test use of list comprehension access in closure and as arg c                 S   s   g | ]}|d  qS rE   r   r=   r   r   r   r   i   r   zMTestListComprehension.test_bulk_use_cases.<locals>.list10.<locals>.<listcomp>c                    s    fdd| D S )Nc                    s   g | ]}| d   qS )r   r   r3   rI   r   r   r   l   r   z\TestListComprehension.test_bulk_use_cases.<locals>.list10.<locals>.inner.<locals>.<listcomp>r   r/   rI   r   r   rA   k   s    zHTestListComprehension.test_bulk_use_cases.<locals>.list10.<locals>.innerr   rJ   r   rI   r   list10g   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list10c                 S   s   dd | D }|S )z6 Test scalar array construction in list comprehension c                 S   s   g | ]}t |qS r   r9   r=   r   r   r   r   q   r   zMTestListComprehension.test_bulk_use_cases.<locals>.list11.<locals>.<listcomp>r   r0   r   r   r   r   list11o   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list11c                 S   s   dd | D }|S )z@ Test scalar type conversion construction in list comprehension c                 S   s   g | ]}t |qS r   )r:   float64r=   r   r   r   r   v   r   zMTestListComprehension.test_bulk_use_cases.<locals>.list12.<locals>.<listcomp>r   rM   r   r   r   list12t   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list12c                 S   s   dd | D }|S )zH Test use of explicit numpy scalar ctor reference in list comprehension c                 S   s   g | ]}t |qS r   )numpyrO   r=   r   r   r   r   {   r   zMTestListComprehension.test_bulk_use_cases.<locals>.list13.<locals>.<listcomp>r   rM   r   r   r   list13y   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list13c                 S   s   dd | D }|S )z@ Test use of python scalar ctor reference in list comprehension c                 S   s   g | ]}t |qS r   floatr=   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list14.<locals>.<listcomp>r   rM   r   r   r   list14~   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list14c                 S   s   dd | D }t |S )zo Test use of python scalar ctor reference in list comprehension followed by np array construction from the listc                 S   s   g | ]}t |qS r   rS   r=   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list15.<locals>.<listcomp>r9   rM   r   r   r   list15   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list15c                 S   s8   dd | D }dd | D }t |}t |}|| S )zH Test type unification from np array ctors consuming list comprehension c                 S   s   g | ]}t |qS r   rS   r=   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list16.<locals>.<listcomp>c                 S   s   g | ]}|qS r   r   r=   r   r   r   r      r   r9   )r0   l1l2ZzeZoer   r   r   list16   s
    

z9TestListComprehension.test_bulk_use_cases.<locals>.list16c                    s    fdd D S )z6 Test complex list comprehension including math calls c              	      sD   g | ]<} D ]2} D ](}t |d  |d   |kr|||fqqqS r2   )r:   sqrt)r   abcr/   r   r   r      s   ,zMTestListComprehension.test_bulk_use_cases.<locals>.list17.<locals>.<listcomp>r   r/   r   r/   r   list17   s    
z9TestListComprehension.test_bulk_use_cases.<locals>.list17	   c                    s$   g }| D ]}| k r| | q|S )z3 Test loop list with outer scope var as conditionalappend)r0   r>   r   _OUTER_SCOPE_VARr   r   list18   s
    z9TestListComprehension.test_bulk_use_cases.<locals>.list18c                    s    fdd| D S )z8 Test list comprehension with outer scope as conditionalc                    s   g | ]}| k r|qS r   r   r   rb   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list19.<locals>.<listcomp>r   r/   rb   r   r   list19   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list19c                 S   s   dd | D S )z Test return empty list c                 S   s   g | ]}|d kr|qS )ir   r   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list20.<locals>.<listcomp>r   r/   r   r   r   list20   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list20c                    s    fdd| D S )z5 Test call a jitted function in a list comprehension c                    s   g | ]} |qS r   r   r   r,   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list21.<locals>.<listcomp>r   r/   r,   r   r   list21   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list21c                    s.   dd | D }dd | D   fdd|D S )zH Test create two lists comprehensions and a third walking the first two c                 S   s   g | ]}|d  qS rE   r   r3   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list22.<locals>.<listcomp>c                 S   s   g | ]}|d  qS rE   r   r3   r   r   r   r      r   c                    s"   g | ]} D ]}||kr|qqS r   r   )r   r0   r4   r\   r   r   r      r   r   )r0   r[   r   rh   r   list22   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list22c                 S   s   dd | D }| d |S )z0 Test operation on comprehension generated list c                 S   s   g | ]}|qS r   r   r3   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list23.<locals>.<listcomp>r*   r`   r0   r>   r   r   r   list23   s    
z9TestListComprehension.test_bulk_use_cases.<locals>.list23c                 S   s   dd | D }|S )z Test type promotion c                 S   s    g | ]}|d krt |n|qS )r8   rS   r3   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list24.<locals>.<listcomp>r   rj   r   r   r   list24   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list24c                    s(   t g d  fddtdD }|S )N)r*   r)         c                    s   g | ]}|t  vr|qS r   )listr   Zincludedr   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list25.<locals>.<listcomp>
   r:   r;   r   )r0   Znot_includedr   rp   r   list25   s    z9TestListComprehension.test_bulk_use_cases.<locals>.list25r*   r)   r8      r   Nl        @       )r   r!   
ValueErrorr:   testingZassert_allclose	ExceptionassertRaisesr   sysmaxsize) r"   r1   r5   r6   r<   r?   rC   rD   rH   rK   rL   rN   rP   rR   rU   rV   rY   r^   rd   re   rf   rg   ri   rk   rl   rs   fvarrefr%   raisesbitsr   )rc   r-   r   test_bulk_use_cases)   sf    	


(z)TestListComprehension.test_bulk_use_casesc                 C   s>   dd }t dd|}g d}||}||}| || d S )Nc                 S   s   t  }dd | D }|S )Nc                 S   s   g | ]}|qS r   r   r   r0   r   r   r   r      r   zUTestListComprehension.test_objmode_inlining.<locals>.objmode_func.<locals>.<listcomp>)object)r4   r>   Zinlinedr   r   r   objmode_func   s    zATestListComprehension.test_objmode_inlining.<locals>.objmode_funcT)Zforceobjr7   )r   ZassertPreciseEqual)r"   r   r%   texpectedgotr   r   r   test_objmode_inlining   s    z+TestListComprehension.test_objmode_inliningN)__name__
__module____qualname__r&   r   r   r   r   r   r   r      s    =r   c                   @   s   e Zd 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d Zdd Zeedk d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d0d1 Zd2d3 Zd4d5 Zd6d7 Z d8S )9TestArrayComprehensionFc           
      O   s   | dd}| dd}| dd}td|d|}|| }|| }	tj||	 |rh| |	d j| |r| d||j	d	  n| 
d||j	d	  |r| d
||j	d	  dS )z^A generic check function that run both pyfunc, and jitted pyfunc,
        and compare results.run_parallelFassert_allocate_listassert_dtypeT)r(   parallelr*   zallocate listr   z@do_schedulingN)getr   r:   ry   Zassert_array_equalr!   dtypeassertInZinspect_llvmZ
signaturesZassertNotIn)
r"   r#   argskwargsr   r   r   r%   Zpyresr$   r   r   r   check   s    zTestArrayComprehension.checkc                 C   s,   dd }|  |d tr(| j |ddd d S )Nc                    s(   | d  t  fddt| D }|S )Nr)   c                    s   g | ]}|  qS r   r   r   mr   r   r     r   z\TestArrayComprehension.test_comp_with_array_1.<locals>.comp_with_array_1.<locals>.<listcomp>rr   r   r   r   r   r   comp_with_array_1
  s    zHTestArrayComprehension.test_comp_with_array_1.<locals>.comp_with_array_1r   Tr   r   PARALLEL_SUPPORTED)r"   r   r   r   r   test_comp_with_array_1	  s    z-TestArrayComprehension.test_comp_with_array_1c                 C   s   dd }|  |dd d S )Nc                    s&   t |  | }t  fdd|D S )Nc                    s$   g | ]}| k r|| n|d  qS r2   r   r   	thresholdr   r   r     r   z\TestArrayComprehension.test_comp_with_array_2.<locals>.comp_with_array_2.<locals>.<listcomp>)r:   Zaranger;   )r   r   Ar   r   r   comp_with_array_2  s    zHTestArrayComprehension.test_comp_with_array_2.<locals>.comp_with_array_2r   r   r   )r"   r   r   r   r   test_comp_with_array_2  s    z-TestArrayComprehension.test_comp_with_array_2c                 C   sH   dd }dd l m  m} z d|_| j|ddd W d|_nd|_0 d S )Nc                    s(   | d  t  fddt| D }|S )Nr)   c                    s   g | ]}|  qS r   r   r   r   r   r   r     r   zjTestArrayComprehension.test_comp_with_array_noinline.<locals>.comp_with_array_noinline.<locals>.<listcomp>rr   r   r   r   r   comp_with_array_noinline  s    zVTestArrayComprehension.test_comp_with_array_noinline.<locals>.comp_with_array_noinliner   Fr   Tr   Znumba.core.inline_closurecallcoreZinline_closurecallZenable_inline_arraycallr   )r"   r   icr   r   r   test_comp_with_array_noinline  s    z4TestArrayComprehension.test_comp_with_array_noinlinec                 C   s   dd }| j |ddd d S )Nc                 S   s,   dg}t | D ]}|| qt|}|S )Nr   )r   ra   r:   r;   )r   lstr   r   r   r   r   r   (  s
    
zaTestArrayComprehension.test_comp_with_array_noinline_issue_6053.<locals>.comp_with_array_noinliner   Tr   r   )r"   r   r   r   r   (test_comp_with_array_noinline_issue_6053'  s    z?TestArrayComprehension.test_comp_with_array_noinline_issue_6053c                 C   s,   dd }|  |d tr(| j |ddd d S )Nc                    s    t  fddt D }|S )Nc                    s"   g | ]  fd dt D qS )c                    s   g | ]} | qS r   r   r   jr   r   r   r   3  r   zmTestArrayComprehension.test_comp_nest_with_array.<locals>.comp_nest_with_array.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r   3  r   zbTestArrayComprehension.test_comp_nest_with_array.<locals>.comp_nest_with_array.<locals>.<listcomp>rr   r   r   r+   r   comp_nest_with_array2  s    zNTestArrayComprehension.test_comp_nest_with_array.<locals>.comp_nest_with_arrayr   Tr   r   )r"   r   r   r   r   test_comp_nest_with_array1  s    z0TestArrayComprehension.test_comp_nest_with_arrayc                 C   s,   dd }|  |d tr(| j |ddd d S )Nc                    s    t  fddt D }|S )Nc                    s$   g | ]  fd dt D qS )c                    s$   g | ]  fd dt D qS )c                    s   g | ]}  | qS r   r   )r   k)r   r   r   r   r   <  r   z|TestArrayComprehension.test_comp_nest_with_array_3.<locals>.comp_nest_with_array_3.<locals>.<listcomp>.<listcomp>.<listcomp>r   r   )r   r   )r   r   r   <  r   zqTestArrayComprehension.test_comp_nest_with_array_3.<locals>.comp_nest_with_array_3.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r   <  r   zfTestArrayComprehension.test_comp_nest_with_array_3.<locals>.comp_nest_with_array_3.<locals>.<listcomp>rr   r   r   r+   r   comp_nest_with_array_3;  s    zRTestArrayComprehension.test_comp_nest_with_array_3.<locals>.comp_nest_with_array_3r   Tr   r   )r"   r   r   r   r   test_comp_nest_with_array_3:  s    z2TestArrayComprehension.test_comp_nest_with_array_3c                 C   sH   dd }dd l m  m} z d|_| j|ddd W d|_nd|_0 d S )Nc                    s    t  fddt D }|S )Nc                    s"   g | ]  fd dt D qS )c                    s   g | ]} | qS r   r   r   r   r   r   r   E  r   zTestArrayComprehension.test_comp_nest_with_array_noinline.<locals>.comp_nest_with_array_noinline.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r   E  r   ztTestArrayComprehension.test_comp_nest_with_array_noinline.<locals>.comp_nest_with_array_noinline.<locals>.<listcomp>rr   r   r   r+   r   comp_nest_with_array_noinlineD  s    z`TestArrayComprehension.test_comp_nest_with_array_noinline.<locals>.comp_nest_with_array_noinliner   Fr   Tr   r   )r"   r   r   r   r   r   "test_comp_nest_with_array_noinlineC  s    z9TestArrayComprehension.test_comp_nest_with_array_noinlinec                 C   s   dd }|  |dd d S )Nc                 S   s   t dd t| |D }|S )Nc                 S   s   g | ]}|qS r   r   r   r   r   r   r   R  r   zdTestArrayComprehension.test_comp_with_array_range.<locals>.comp_with_array_range.<locals>.<listcomp>rr   r   r   r   r   r   r   comp_with_array_rangeQ  s    zPTestArrayComprehension.test_comp_with_array_range.<locals>.comp_with_array_ranger   rq   r   )r"   r   r   r   r   test_comp_with_array_rangeP  s    z1TestArrayComprehension.test_comp_with_array_rangec                 C   s   dd }|  |dd d S )Nc                 S   s    t dd t| |dD }|S )Nc                 S   s   g | ]}|qS r   r   r   r   r   r   r   Y  r   zvTestArrayComprehension.test_comp_with_array_range_and_step.<locals>.comp_with_array_range_and_step.<locals>.<listcomp>r)   rr   r   r   r   r   comp_with_array_range_and_stepX  s    zbTestArrayComprehension.test_comp_with_array_range_and_step.<locals>.comp_with_array_range_and_stepr   rq   r   )r"   r   r   r   r   #test_comp_with_array_range_and_stepW  s    z:TestArrayComprehension.test_comp_with_array_range_and_stepc                 C   s   dd }| j |ddd d S )Nc                 S   s   t dd t| D }|S )Nc                 S   s   g | ]}|d  dkr|qS )r)   r*   r   r   r   r   r   r   `  r   zpTestArrayComprehension.test_comp_with_array_conditional.<locals>.comp_with_array_conditional.<locals>.<listcomp>rr   r   r   r   r   comp_with_array_conditional_  s    z\TestArrayComprehension.test_comp_with_array_conditional.<locals>.comp_with_array_conditionalrq   Tr   r   )r"   r   r   r   r    test_comp_with_array_conditional^  s    z7TestArrayComprehension.test_comp_with_array_conditionalc                 C   s   dd }| j |ddd d S )Nc                    s    t  fddt D }|S )Nc                    s.   g | ]&  d  dkr fddt D qS )r)   r*   c                    s   g | ]} | qS r   r   r   r   r   r   r   g  r   zTestArrayComprehension.test_comp_nest_with_array_conditional.<locals>.comp_nest_with_array_conditional.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r   g  r   zzTestArrayComprehension.test_comp_nest_with_array_conditional.<locals>.comp_nest_with_array_conditional.<locals>.<listcomp>rr   r   r   r+   r    comp_nest_with_array_conditionalf  s    zfTestArrayComprehension.test_comp_nest_with_array_conditional.<locals>.comp_nest_with_array_conditionalr   Tr   r   )r"   r   r   r   r   %test_comp_nest_with_array_conditionale  s    z<TestArrayComprehension.test_comp_nest_with_array_conditional)r*      zASetting an array element with a sequence is removed in NumPy 1.24c                 C   sf   dd }|  t}| |d W d    n1 s40    Y  | tt|j | dt|j d S )Nc                 S   s   t dd t| D }|S )Nc                    s&   g | ]  fd dt  d D qS )c                    s   g | ]} | qS r   r   r   r   r   r   r   q  r   zwTestArrayComprehension.test_comp_nest_with_dependency.<locals>.comp_nest_with_dependency.<locals>.<listcomp>.<listcomp>r*   r   r   r   r   r   r   q  r   zlTestArrayComprehension.test_comp_nest_with_dependency.<locals>.comp_nest_with_dependency.<locals>.<listcomp>rr   r   r   r   r   comp_nest_with_dependencyp  s    zXTestArrayComprehension.test_comp_nest_with_dependency.<locals>.comp_nest_with_dependencyr   zarray(undefined,r{   r   r   r   r
   str	exception)r"   r   r   r   r   r   test_comp_nest_with_dependencyl  s
    *z5TestArrayComprehension.test_comp_nest_with_dependencyc                 C   sd   dd }|  t}| | W d    n1 s20    Y  | tt|j | dt|j d S )Nc                  S   s&   t g dg d} tdd | D S )Nr7   )ru   r   rm   c                 S   s   g | ]\}}|qS r   r   )r   r[   r\   r   r   r   r   |  r   zdTestArrayComprehension.test_comp_unsupported_iter.<locals>.comp_unsupported_iter.<locals>.<listcomp>)zipr:   r;   )valr   r   r   comp_unsupported_iterz  s    zPTestArrayComprehension.test_comp_unsupported_iter.<locals>.comp_unsupported_iterz1Unsupported iterator found in array comprehensionr   )r"   r   r   r   r   r   test_comp_unsupported_itery  s    (z1TestArrayComprehension.test_comp_unsupported_iterc                 C   s4   dd }| j |ddd dd }| j |ddd d S )	Nc                 S   s   g d}t |}|S )Nr*   r)   r8   ru   r9   r   r   r[   r   r   r   no_array_comp1  s    
zATestArrayComprehension.test_no_array_comp.<locals>.no_array_comp1rq   Fr   c                 S   s    g d}t |}|d |S )Nr   r   )r:   r;   ra   r   r   r   r   no_array_comp2  s    

zATestArrayComprehension.test_no_array_comp.<locals>.no_array_comp2Tr   )r"   r   r   r   r   r   test_no_array_comp  s    z)TestArrayComprehension.test_no_array_compc                 C   s   dd }|  |d d S )Nc                    s    t  fddt D }|S )Nc                    s$   g | ]}t d d t D qS )c                 S   s   g | ]}|qS r   r   r   r   r   r   r     r   z]TestArrayComprehension.test_nested_array.<locals>.nested_array.<locals>.<listcomp>.<listcomp>rr   r3   r+   r   r   r     r   zRTestArrayComprehension.test_nested_array.<locals>.nested_array.<locals>.<listcomp>rr   r   r   r+   r   nested_array  s    z>TestArrayComprehension.test_nested_array.<locals>.nested_arrayrq   r   r"   r   r   r   r   test_nested_array  s    z(TestArrayComprehension.test_nested_arrayc                 C   s   dd }|  |d d S )Nc                 S   s   t dd tdD }|S )Nc                 S   s$   g | ]}t d d tdD qS )c                 S   s   g | ]}|qS r   r   r   r   r   r   r     r   zhTestArrayComprehension.test_nested_array_with_const.<locals>.nested_array.<locals>.<listcomp>.<listcomp>r8   rr   r3   r   r   r   r     r   z]TestArrayComprehension.test_nested_array_with_const.<locals>.nested_array.<locals>.<listcomp>ru   rr   r   r   r   r   r     s    zITestArrayComprehension.test_nested_array_with_const.<locals>.nested_arrayr   r   r   r   r   r   test_nested_array_with_const  s    z3TestArrayComprehension.test_nested_array_with_constc                 C   sT   dd }g d}|  || |  |t| |  |t| |  |t| d S )Nc                 S   s   t dd | D }|S )Nc                 S   s   g | ]}|| qS r   r   r   r   r   r   r     r   zXTestArrayComprehension.test_array_comp_with_iter.<locals>.array_comp.<locals>.<listcomp>r9   )r[   r   r   r   r   
array_comp  s    zDTestArrayComprehension.test_array_comp_with_iter.<locals>.array_comprt   )r   r:   r;   tupler   List)r"   r   r   r   r   r   test_array_comp_with_iter  s    z0TestArrayComprehension.test_array_comp_with_iterc                 C   s   dd }| j |dtjd d S )Nc                 S   s"   t jdd t| D t jd}|S )Nc                 S   s   g | ]}|qS r   r   r   r   r   r   r     r   zYTestArrayComprehension.test_array_comp_with_dtype.<locals>.array_comp.<locals>.<listcomp>)r   )r:   r;   r   	complex64r   r   r   r   r     s    zETestArrayComprehension.test_array_comp_with_dtype.<locals>.array_comprq   r   )r   r:   r   r"   r   r   r   r   test_array_comp_with_dtype  s    z1TestArrayComprehension.test_array_comp_with_dtypec                 C   s   dd }|  |d d S )Nc                 S   s   t dd t| D }|S )Nc                 S   s   g | ]}|d  qS )y              ?r   r   r   r   r   r     r   z]TestArrayComprehension.test_array_comp_inferred_dtype.<locals>.array_comp.<locals>.<listcomp>rr   r   r   r   r   r     s    zITestArrayComprehension.test_array_comp_inferred_dtype.<locals>.array_comprq   r   r   r   r   r   test_array_comp_inferred_dtype  s    z5TestArrayComprehension.test_array_comp_inferred_dtypec                 C   s   dd }|  |d d S )Nc                    s    t  fddt D }|S )Nc                    s"   g | ]  fd dt D qS )c                    s   g | ]} | qS r   r   r   r   r   r   r     r   zoTestArrayComprehension.test_array_comp_inferred_dtype_nested.<locals>.array_comp.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r     r   zdTestArrayComprehension.test_array_comp_inferred_dtype_nested.<locals>.array_comp.<locals>.<listcomp>rr   r   r   r+   r   r     s    zPTestArrayComprehension.test_array_comp_inferred_dtype_nested.<locals>.array_comprq   r   r   r   r   r   %test_array_comp_inferred_dtype_nested  s    z<TestArrayComprehension.test_array_comp_inferred_dtype_nestedc                 C   s   dd }|  |d d S )Nc                    s    t  fddt D }|S )Nc                    s"   g | ]  fd dt D qS )c                    s   g | ]} | qS r   r   r   r   r   r   r     r   zsTestArrayComprehension.test_array_comp_inferred_dtype_nested_sum.<locals>.array_comp.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r     r   zhTestArrayComprehension.test_array_comp_inferred_dtype_nested_sum.<locals>.array_comp.<locals>.<listcomp>rr   r   r   r+   r   r     s    zTTestArrayComprehension.test_array_comp_inferred_dtype_nested_sum.<locals>.array_comprq   r   r   r   r   r   )test_array_comp_inferred_dtype_nested_sum  s    z@TestArrayComprehension.test_array_comp_inferred_dtype_nested_sumc                 C   s   dd }d}| j |d|tjd | t(}tdd|}|dd W d    n1 sX0    Y  | td	t	j
 t|j | d
tjt|j d S )Nc                 S   s$   t dd t| D }||d< |S )Nc                 S   s   g | ]}|qS r   r   r   r   r   r   r     r   zmTestArrayComprehension.test_array_comp_inferred_dtype_outside_setitem.<locals>.array_comp.<locals>.<listcomp>r   rr   )r   vZarrr   r   r   r     s    zYTestArrayComprehension.test_array_comp_inferred_dtype_outside_setitem.<locals>.array_compg333333?rq   r   Tr'   y        ffffff@z Function({})z/(array({}, 1d, C), Literal[int](0), complex128))r   r:   r   r{   r   r   r   r
   formatoperatorsetitemr   r   r   )r"   r   r   r   r%   r   r   r   .test_array_comp_inferred_dtype_outside_setitem  s    (
zETestArrayComprehension.test_array_comp_inferred_dtype_outside_setitemc                    s   d t dd fdd}t }|  W d    n1 s<0    Y  |  }t ,}ttdd t D  W d    n1 s0    Y  |  }| || | 	|d d S )	Nd   Tr'   c                     s0   t dd t D } t j|  t|  d S )Nc                 S   s   g | ]}|qS r   r   r   r   r   r   r     r   zZTestArrayComprehension.test_array_comp_shuffle_sideeffect.<locals>.foo.<locals>.<listcomp>)r:   r;   r   randomshuffleprint)ZnumbersZnelemr   r   foo  s    zFTestArrayComprehension.test_array_comp_shuffle_sideeffect.<locals>.fooc                 S   s   g | ]}|qS r   r   r   r   r   r   r     r   zMTestArrayComprehension.test_array_comp_shuffle_sideeffect.<locals>.<listcomp>z\[(\s*\d+)+\])
r   r   getvaluestripr   r:   r;   r   ZassertNotEqualZassertRegexpMatches)r"   r   Zgotbufr   Z	expectbufexpectr   r   r   "test_array_comp_shuffle_sideeffect  s    $:z9TestArrayComprehension.test_array_comp_shuffle_sideeffectc                 C   s   dd }| j |ddd d S )Nc                 S   s0   g }t dg}t j|d}|| |  |S r@   )r:   r;   r   choicera   )r0   r   ZmyListr[   r   r   r   r~     s
    z=TestArrayComprehension.test_empty_list_not_removed.<locals>.fr   Tr   r   )r"   r~   r   r   r   test_empty_list_not_removed  s    z2TestArrayComprehension.test_empty_list_not_removedc                 C   s   dd }| j |ddd dS )z Test issue 3742 c                 S   s@   dd t dD  t| }t | D ]}t| }|||< q$|S )Nc                 S   s   g | ]}|qS r   r   r   r   r   r   r     r   zOTestArrayComprehension.test_reuse_of_array_var.<locals>.foo.<locals>.<listcomp>r*   )r   r:   emptyzeros)r   r>   r   r   r   r   r     s    


z;TestArrayComprehension.test_reuse_of_array_var.<locals>.foorq   Tr   Nr   )r"   r   r   r   r   test_reuse_of_array_var  s    z.TestArrayComprehension.test_reuse_of_array_varN)!r   r   r   Z_numba_parallel_test_r   r   r   r   r   r   r   r   r   r   r   r   unittestZ
skipUnlessr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s<   

		




r   __main__)r   Znumba.tests.supportr   r|   r   rQ   r:   Znumba.core.compilerr   Znumbar   r   Z
numba.corer   r   Znumba.core.errorsr   r	   Znumba.core.types.functionsr
   Znumba.np.numpy_supportr   r   r   r   r   r   r   r   r   mainr   r   r   r   <module>   s*    T  "