o
    8ήcD                     @   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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rje   dS dS )    N)TestCase)compile_isolated)jittyped)typesutils)TypingErrorLoweringError)_header_lead)tag_32bitcaptured_stdoutc                 C   s,   dd t | D }d}|D ]}||7 }q|S )Nc                 S      g | ]}|qS  r   .0ir   r   E/tmp/pip-target-vg8gfxp4/lib/python/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 ]4}zt dd|}| |||| W q ty   ztj|||| W n ty    w Y qw | t}t dd|}|| W d9   n1 sw   Y  t	j
d:krd;}d9S 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   r   r   r   r   r   r   r   r   4   r   zLTestListComprehension.test_bulk_use_cases.<locals>.list1.<locals>.<listcomp>r*   )r   lenxr   r   r   list12   s   z8TestListComprehension.test_bulk_use_cases.<locals>.list1c                 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   8       zLTestListComprehension.test_bulk_use_cases.<locals>.list2.<locals>.<listcomp>r   r/   r   r   r   list26      z8TestListComprehension.test_bulk_use_cases.<locals>.list2c                 S   r2   )z! Test ternary list comprehension c                 S   s   g | ]
}|d k r
|ndqS )r)   r   r   r4   r   r   r   r   <       zLTestListComprehension.test_bulk_use_cases.<locals>.list3.<locals>.<listcomp>r   r/   r   r   r   list3:   r8   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>   r8   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   r   r   r   r   zr   r   r   r   E   r   zWTestListComprehension.test_bulk_use_cases.<locals>.list5.<locals>.<listcomp>.<listcomp>r=   r4   r/   r   r   r   E        zLTestListComprehension.test_bulk_use_cases.<locals>.list5.<locals>.<listcomp>r=   r/   r   r/   r   list5C   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   innerI      zGTestListComprehension.test_bulk_use_cases.<locals>.list6.<locals>.innerc                       g | ]} |qS r   r   rA   rF   r   r   r   K       zLTestListComprehension.test_bulk_use_cases.<locals>.list6.<locals>.<listcomp>r   r/   r   rI   r   list6G   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 r<   c                    s   |   S )Nr   r/   )r5   r   r   rF   Q   rG   zGTestListComprehension.test_bulk_use_cases.<locals>.list7.<locals>.innerc                    rH   r   r   rA   rI   r   r   r   S   rJ   zLTestListComprehension.test_bulk_use_cases.<locals>.list7.<locals>.<listcomp>r   r/   r   )rF   r5   r   list7M   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      g | ]}|d  qS r*   r   rA   r   r   r   r   W   rJ   zLTestListComprehension.test_bulk_use_cases.<locals>.list8.<locals>.<listcomp>c                 S   s   | d d S Nr   r*   r   r/   r   r   r   rF   Y   s   zGTestListComprehension.test_bulk_use_cases.<locals>.list8.<locals>.innerr   )r0   r   rF   qr   r   r   list8U   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   rM   rN   r   rA   r   r   r   r   `   rJ   zLTestListComprehension.test_bulk_use_cases.<locals>.list9.<locals>.<listcomp>c                    s   | d  d  S rO   r   r/   r   r   r   rF   b   s   zGTestListComprehension.test_bulk_use_cases.<locals>.list9.<locals>.innerr   r0   rF   r   rR   r   list9^      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   rM   rN   r   rA   r   r   r   r   h   rJ   zMTestListComprehension.test_bulk_use_cases.<locals>.list10.<locals>.<listcomp>c                        fdd| D S )Nc                    s   g | ]}| d   qS )r   r   r4   rR   r   r   r   k   r6   z\TestListComprehension.test_bulk_use_cases.<locals>.list10.<locals>.inner.<locals>.<listcomp>r   r/   rR   r   r   rF   j   s   zHTestListComprehension.test_bulk_use_cases.<locals>.list10.<locals>.innerr   rS   r   rR   r   list10f   rU   z9TestListComprehension.test_bulk_use_cases.<locals>.list10c                 S      dd | D }|S )z6 Test scalar array construction in list comprehension c                 S      g | ]}t |qS r   r=   rA   r   r   r   r   p       zMTestListComprehension.test_bulk_use_cases.<locals>.list11.<locals>.<listcomp>r   r0   r   r   r   r   list11n      z9TestListComprehension.test_bulk_use_cases.<locals>.list11c                 S   rX   )z@ Test scalar type conversion construction in list comprehension c                 S   rY   r   )r>   float64rA   r   r   r   r   u   rZ   zMTestListComprehension.test_bulk_use_cases.<locals>.list12.<locals>.<listcomp>r   r[   r   r   r   list12s   r]   z9TestListComprehension.test_bulk_use_cases.<locals>.list12c                 S   rX   )zH Test use of explicit numpy scalar ctor reference in list comprehension c                 S   rY   r   )numpyr^   rA   r   r   r   r   z   rZ   zMTestListComprehension.test_bulk_use_cases.<locals>.list13.<locals>.<listcomp>r   r[   r   r   r   list13x   r]   z9TestListComprehension.test_bulk_use_cases.<locals>.list13c                 S   rX   )z@ Test use of python scalar ctor reference in list comprehension c                 S      g | ]}t |qS r   floatrA   r   r   r   r      rJ   zMTestListComprehension.test_bulk_use_cases.<locals>.list14.<locals>.<listcomp>r   r[   r   r   r   list14}   r]   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   rb   r   rc   rA   r   r   r   r      rJ   zMTestListComprehension.test_bulk_use_cases.<locals>.list15.<locals>.<listcomp>r=   r[   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   rb   r   rc   rA   r   r   r   r      rJ   zMTestListComprehension.test_bulk_use_cases.<locals>.list16.<locals>.<listcomp>c                 S   r   r   r   rA   r   r   r   r      r   r=   )r0   l1l2ze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 ]} D ]}t |d  |d   |kr
|||fq
qqS r3   )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   rB   r   _OUTER_SCOPE_VARr   r   list18   s   
z9TestListComprehension.test_bulk_use_cases.<locals>.list18c                    rV   )z8 Test list comprehension with outer scope as conditionalc                    s   g | ]}| k r|qS r   r   r   rt   r   r   r      r6   zMTestListComprehension.test_bulk_use_cases.<locals>.list19.<locals>.<listcomp>r   r/   rt   r   r   list19      z9TestListComprehension.test_bulk_use_cases.<locals>.list19c                 S   r2   )z Test return empty list c                 S   s   g | ]}|d kr|qS )ir   r   r   r   r   r      r6   zMTestListComprehension.test_bulk_use_cases.<locals>.list20.<locals>.<listcomp>r   r/   r   r   r   list20   r8   z9TestListComprehension.test_bulk_use_cases.<locals>.list20c                    rV   )z5 Test call a jitted function in a list comprehension c                    rH   r   r   r   r,   r   r   r      rJ   zMTestListComprehension.test_bulk_use_cases.<locals>.list21.<locals>.<listcomp>r   r/   r,   r   r   list21   rx   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 rN   r   r4   r   r   r   r      rJ   zMTestListComprehension.test_bulk_use_cases.<locals>.list22.<locals>.<listcomp>c                 S   rM   rN   r   r4   r   r   r   r      rJ   c                    s"   g | ]} D ]}||kr|qqS r   r   )r   r0   r5   rn   r   r   r         " r   )r0   rm   r   r{   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   r   r   r   r4   r   r   r   r      r   zMTestListComprehension.test_bulk_use_cases.<locals>.list23.<locals>.<listcomp>r*   rr   r0   rB   r   r   r   list23   s   
z9TestListComprehension.test_bulk_use_cases.<locals>.list23c                 S   rX   )z Test type promotion c                 S   s    g | ]}|d krt |n|qS )r<   rc   r4   r   r   r   r      rC   zMTestListComprehension.test_bulk_use_cases.<locals>.list24.<locals>.<listcomp>r   r~   r   r   r   list24   r]   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   includedr   r   r      r9   zMTestListComprehension.test_bulk_use_cases.<locals>.list25.<locals>.<listcomp>
   r>   r?   r   )r0   not_includedr   r   r   list25   s   z9TestListComprehension.test_bulk_use_cases.<locals>.list25r*   r)   r<      r   Nl        @       )r   r!   
ValueErrorr>   testingassert_allclose	ExceptionassertRaisesr   sysmaxsize) r"   r1   r7   r:   r@   rD   rK   rL   rQ   rT   rW   r\   r_   ra   re   rf   rk   rp   rv   rw   ry   rz   r}   r   r   r   fvarrefr%   raisesbitsr   )ru   r-   r   test_bulk_use_cases(   sn   	




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   r   r   r   r   r0   r   r   r   r      r   zUTestListComprehension.test_objmode_inlining.<locals>.objmode_func.<locals>.<listcomp>)object)r5   rB   inlinedr   r   r   objmode_func   s   zATestListComprehension.test_objmode_inlining.<locals>.objmode_funcT)forceobjr;   )r   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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d0d1 Zd2d3 Zd4d5 Zd6S )7TestArrayComprehensionFc           
      O   s   | dd}| dd}| dd}td|d|}|| }|| }	tj||	 |r4| |	d j| |rC| d||j	d	  n| 
d||j	d	  |r_| d
||j	d	  dS 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>   r   assert_array_equalr!   dtypeassertIninspect_llvm
signaturesassertNotIn)
r"   r#   argskwargsr   r   r   r%   pyresr$   r   r   r   check   s   zTestArrayComprehension.checkc                 C   0   dd }|  |d tr| j |ddd d S d S )Nc                    (   | d  t  fddt| D }|S )Nr)   c                       g | ]}|  qS r   r   r   mr   r   r     rJ   z\TestArrayComprehension.test_comp_with_array_1.<locals>.comp_with_array_1.<locals>.<listcomp>r   r   r   r   r   r   comp_with_array_1	     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      dd }|  |dd d S )Nc                    s&   t |  | }t  fdd|D S )Nc                    s$   g | ]}| k r|| n|d  qS r3   r   r   	thresholdr   r   r        $ z\TestArrayComprehension.test_comp_with_array_2.<locals>.comp_with_array_2.<locals>.<listcomp>)r>   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     z-TestArrayComprehension.test_comp_with_array_2c                 C   F   dd }dd l m  m} zd|_| j|ddd W d|_d S d|_w )Nc                    r   )Nr)   c                    r   r   r   r   r   r   r   r     rJ   zjTestArrayComprehension.test_comp_with_array_noinline.<locals>.comp_with_array_noinline.<locals>.<listcomp>r   r   r   r   r   comp_with_array_noinline  r   zVTestArrayComprehension.test_comp_with_array_noinline.<locals>.comp_with_array_noinliner   Fr   Tr   numba.core.inline_closurecallcoreinline_closurecallenable_inline_arraycallr   )r"   r   icr   r   r   test_comp_with_array_noinline  s   z4TestArrayComprehension.test_comp_with_array_noinlinec                 C      dd }| j |ddd d S )Nc                 S   s,   dg}t | D ]}|| qt|}|S )Nr   )r   rs   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   r   )Nc                        t  fddt D }|S )Nc                    "   g | ]  fd dt D qS )c                       g | ]} | qS r   r   r   jr   r   r   r   2  rJ   zmTestArrayComprehension.test_comp_nest_with_array.<locals>.comp_nest_with_array.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r   2  r|   zbTestArrayComprehension.test_comp_nest_with_array.<locals>.comp_nest_with_array.<locals>.<listcomp>r   r   r   r+   r   comp_nest_with_array1     zNTestArrayComprehension.test_comp_nest_with_array.<locals>.comp_nest_with_arrayr   Tr   r   )r"   r   r   r   r   test_comp_nest_with_array0  
   z0TestArrayComprehension.test_comp_nest_with_arrayc                 C   r   )Nc                    r   )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   ;  r6   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>r   r   r   r+   r   comp_nest_with_array_3:  r   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_39  r   z2TestArrayComprehension.test_comp_nest_with_array_3c                 C   r   )Nc                    r   )Nc                    r   )c                    r   r   r   r   r   r   r   r   D  rJ   zTestArrayComprehension.test_comp_nest_with_array_noinline.<locals>.comp_nest_with_array_noinline.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r   D  r|   ztTestArrayComprehension.test_comp_nest_with_array_noinline.<locals>.comp_nest_with_array_noinline.<locals>.<listcomp>r   r   r   r+   r   comp_nest_with_array_noinlineC  r   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_noinlineB  s   z9TestArrayComprehension.test_comp_nest_with_array_noinlinec                 C   r   )Nc                 S   s   t dd t| |D }|S )Nc                 S   r   r   r   r   r   r   r   r   Q  r   zdTestArrayComprehension.test_comp_with_array_range.<locals>.comp_with_array_range.<locals>.<listcomp>r   r   r   r   r   r   r   comp_with_array_rangeP  s   zPTestArrayComprehension.test_comp_with_array_range.<locals>.comp_with_array_ranger   r   r   )r"   r   r   r   r   test_comp_with_array_rangeO  r   z1TestArrayComprehension.test_comp_with_array_rangec                 C   r   )Nc                 S   s    t dd t| |dD }|S )Nc                 S   r   r   r   r   r   r   r   r   X  r   zvTestArrayComprehension.test_comp_with_array_range_and_step.<locals>.comp_with_array_range_and_step.<locals>.<listcomp>r)   r   r   r   r   r   comp_with_array_range_and_stepW  r   zbTestArrayComprehension.test_comp_with_array_range_and_step.<locals>.comp_with_array_range_and_stepr   r   r   )r"   r   r   r   r   #test_comp_with_array_range_and_stepV  r   z:TestArrayComprehension.test_comp_with_array_range_and_stepc                 C   r   )Nc                 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   _  r9   zpTestArrayComprehension.test_comp_with_array_conditional.<locals>.comp_with_array_conditional.<locals>.<listcomp>r   r   r   r   r   comp_with_array_conditional^     z\TestArrayComprehension.test_comp_with_array_conditional.<locals>.comp_with_array_conditionalr   Tr   r   )r"   r   r   r   r    test_comp_with_array_conditional]  s   z7TestArrayComprehension.test_comp_with_array_conditionalc                 C   r   )Nc                    r   )Nc                    s.   g | ]  d  dkr fddt D qS )r)   r*   c                    r   r   r   r   r   r   r   r   f  rJ   zTestArrayComprehension.test_comp_nest_with_array_conditional.<locals>.comp_nest_with_array_conditional.<locals>.<listcomp>.<listcomp>r   r   r+   r   r   r   f  s   . zzTestArrayComprehension.test_comp_nest_with_array_conditional.<locals>.comp_nest_with_array_conditional.<locals>.<listcomp>r   r   r   r+   r    comp_nest_with_array_conditionale  r   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_conditionald  s   
z<TestArrayComprehension.test_comp_nest_with_array_conditionalc                 C   sf   dd }|  t}| |d W d    n1 sw   Y  | tt|j | dt|j d S )Nc                 S   r   )Nc                    s&   g | ]  fd dt  d D qS )c                    r   r   r   r   r   r   r   r   m  rJ   zwTestArrayComprehension.test_comp_nest_with_dependency.<locals>.comp_nest_with_dependency.<locals>.<listcomp>.<listcomp>r*   r   r   r   r   r   r   m  s   & zlTestArrayComprehension.test_comp_nest_with_dependency.<locals>.comp_nest_with_dependency.<locals>.<listcomp>r   r   r   r   r   comp_nest_with_dependencyl  r   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_dependencyk  s   z5TestArrayComprehension.test_comp_nest_with_dependencyc                 C   sd   dd }|  t}| | W d    n1 sw   Y  | tt|j | dt|j d S )Nc                  S   s&   t g dg d} tdd | D S )Nr;   )r   r   r   c                 S   s   g | ]\}}|qS r   r   )r   rm   rn   r   r   r   r   x  rJ   zdTestArrayComprehension.test_comp_unsupported_iter.<locals>.comp_unsupported_iter.<locals>.<listcomp>)zipr>   r?   )valr   r   r   comp_unsupported_iterv  s   zPTestArrayComprehension.test_comp_unsupported_iter.<locals>.comp_unsupported_iterz1Unsupported iterator found in array comprehensionr   )r"   r   r   r   r   r   test_comp_unsupported_iteru  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)   r<   r   r=   r   r   rm   r   r   r   no_array_comp1  s   
zATestArrayComprehension.test_no_array_comp.<locals>.no_array_comp1r   Fr   c                 S   s    g d}t |}|d |S )Nr   r   )r>   r?   rs   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      dd }|  |d d S )Nc                    r   )Nc                    s$   g | ]}t d d t D qS )c                 S   r   r   r   r   r   r   r   r     r   z]TestArrayComprehension.test_nested_array.<locals>.nested_array.<locals>.<listcomp>.<listcomp>r   r4   r+   r   r   r     r   zRTestArrayComprehension.test_nested_array.<locals>.nested_array.<locals>.<listcomp>r   r   r   r+   r   nested_array  r   z>TestArrayComprehension.test_nested_array.<locals>.nested_arrayr   r   r"   r  r   r   r   test_nested_array     z(TestArrayComprehension.test_nested_arrayc                 C   r  )Nc                 S   s   t dd tdD }|S )Nc                 S   s$   g | ]}t d d tdD qS )c                 S   r   r   r   r   r   r   r   r     r   zhTestArrayComprehension.test_nested_array_with_const.<locals>.nested_array.<locals>.<listcomp>.<listcomp>r<   r   r4   r   r   r   r     r   z]TestArrayComprehension.test_nested_array_with_const.<locals>.nested_array.<locals>.<listcomp>r   r   r   r   r   r   r    r   zITestArrayComprehension.test_nested_array_with_const.<locals>.nested_arrayr   r   r  r   r   r   test_nested_array_with_const  r  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     rJ   zXTestArrayComprehension.test_array_comp_with_iter.<locals>.array_comp.<locals>.<listcomp>r=   )rm   r   r   r   r   
array_comp  s   zDTestArrayComprehension.test_array_comp_with_iter.<locals>.array_compr   )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   r   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_compr   r   )r   r>   r  r"   r
  r   r   r   test_array_comp_with_dtype  s   z1TestArrayComprehension.test_array_comp_with_dtypec                 C   r  )Nc                 S   r   )Nc                 S   s   g | ]}|d  qS )y              ?r   r   r   r   r   r     rJ   z]TestArrayComprehension.test_array_comp_inferred_dtype.<locals>.array_comp.<locals>.<listcomp>r   r   r   r   r   r
    r   zITestArrayComprehension.test_array_comp_inferred_dtype.<locals>.array_compr   r   r  r   r   r   test_array_comp_inferred_dtype  r  z5TestArrayComprehension.test_array_comp_inferred_dtypec                 C   r  )Nc                    r   )Nc                    r   )c                    r   r   r   r   r   r   r   r     rJ   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>r   r   r   r+   r   r
    r   zPTestArrayComprehension.test_array_comp_inferred_dtype_nested.<locals>.array_compr   r   r  r   r   r   %test_array_comp_inferred_dtype_nested  r  z<TestArrayComprehension.test_array_comp_inferred_dtype_nestedc                 C   r  )Nc                    r   )Nc                    r   )c                    r   r   r   r   r   r   r   r     rJ   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>r   r   r   r+   r   r
    s   zTTestArrayComprehension.test_array_comp_inferred_dtype_nested_sum.<locals>.array_compr   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 s,w   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   r   r   r   r   r   r   r   r     r   zmTestArrayComprehension.test_array_comp_inferred_dtype_outside_setitem.<locals>.array_comp.<locals>.<listcomp>r   r   )r   varrr   r   r   r
    s   zYTestArrayComprehension.test_array_comp_inferred_dtype_outside_setitem.<locals>.array_compg333333?r   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w   Y  |  }t }ttdd t D  W d    n1 sEw   Y  |  }| || | 	|d d S )	Nd   Tr'   c                     s0   t dd t D } t j|  t|  d S )Nc                 S   r   r   r   r   r   r   r   r     r   zZTestArrayComprehension.test_array_comp_shuffle_sideeffect.<locals>.foo.<locals>.<listcomp>)r>   r?   r   randomshuffleprint)numbersnelemr   r   foo  s   zFTestArrayComprehension.test_array_comp_shuffle_sideeffect.<locals>.fooc                 S   r   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   assertNotEqualassertRegexpMatches)r"   r"  gotbufr   	expectbufexpectr   r   r   "test_array_comp_shuffle_sideeffect  s   z9TestArrayComprehension.test_array_comp_shuffle_sideeffectc                 C   r   )Nc                 S   s0   g }t dg}t j|d}|| |  |S rE   )r>   r?   r  choicers   )r0   r   myListrm   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   r   r   r   r   r   r   r   r     r   zOTestArrayComprehension.test_reuse_of_array_var.<locals>.foo.<locals>.<listcomp>r*   )r   r>   emptyzeros)r   rB   r   r   r   r   r"     s   


z;TestArrayComprehension.test_reuse_of_array_var.<locals>.foor   Tr   Nr   )r"   r"  r   r   r   test_reuse_of_array_var  s   z.TestArrayComprehension.test_reuse_of_array_varN)r   r   r   _numba_parallel_test_r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r  r  r*  r-  r0  r   r   r   r   r      s8    

		


r   __main__)unittestnumba.tests.supportr   r   r  r`   r>   numba.core.compilerr   numbar   r   
numba.corer   r   numba.core.errorsr   r	   numba.core.types.functionsr
   r   r   r   r   r   r   r   r   mainr   r   r   r   <module>   s,     T  