o
    1&i                     @   s  d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZ	d dl
mZmZmZmZmZ d dl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 e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 Z0d4d5 Z1d6d7 Z2d8d9 Z3d:d; Z4d<d= Z5d>d? Z6d@dA Z7dBdC Z8dDdE Z9dFdG Z:dHdI Z;dJdK Z<dLdM Z=dNdO Z>dPdQ Z?dRdS Z@dTdU ZAdVdW ZBdXdY ZCdZd[ ZDd\d] ZEd^d_ ZFd`da ZGdbdc ZHddde ZIdfdg ZJdhdi ZKdjdk ZLdldm ZMdndo ZNdpdq ZOdrds ZPdtdu ZQdvdw ZRdxdy ZSdzd{ ZTd|d} ZUd~d ZVdd ZWdd ZXdd ZYdd ZZdd Z[G dd deeZ\G dd deeZ]G dd deeZ^G dd deeZ_G dd de_Z`dd ZaG dd de_ZbG dd decZdG dd decZeG dd de_ZfG dd deeZgG dd deeZheidkrej  dS dS )    )
namedtupleN)jittypeofnjitliteral_unroll	literally)typeserrors)TestCaseMemoryLeakMixin)jitclass)overloadPointabc                 C      d S N xr   r   AC:\wamp64\www\opt\env\Lib\site-packages\numba/tests/test_lists.pynoop      r   c                 C   s   d}| D ]}||7 }q|S )z"
    Expect a list of numbers
    r   r   r   resvr   r   r   unbox_usecase   s   
r   c                 C   s   d}| D ]}|t |7 }q|S )z!
    Expect a list of tuples
    r   lenr   r   r   r   unbox_usecase2    s   r    c                 C   s"   | \}}|}|D ]}||7 }q|S )z3
    Expect a (number, list of numbers) tuple.
    r   r   r   r   r   r   r   r   r   unbox_usecase3)   s
   
r"   c                 C   s&   | \}}|}|D ]}|t |7 }q|S )z2
    Expect a (number, list of tuples) tuple.
    r   r!   r   r   r   unbox_usecase43   s
   r#   c                 C   s
   | ||gS r   r   )r   yzr   r   r   create_list>   s   
r&   c                 C   s   | ||g|||ggS r   r   )r   r$   r%   r   r   cr   r   r   create_nested_listA   s   r(   c                   C      t dd tdD S )Nc                 S   s   g | ]}|d  qS    r   .0r   r   r   r   
<listcomp>E       z'list_comprehension1.<locals>.<listcomp>
   sumranger   r   r   r   list_comprehension1D      r4   c                   C   r)   )Nc                 S   s   g | ]
}|d  dkr|qS )r+   r   r   r,   r   r   r   r.   H   s    z'list_comprehension2.<locals>.<listcomp>r0   r1   r   r   r   r   list_comprehension2G   r5   r6   c                   C   r)   )Nc                 S   s   g | ]}t |d qS r*   )mathpowr,   r   r   r   r.   K       z'list_comprehension3.<locals>.<listcomp>r0   r1   r   r   r   r   list_comprehension3J   r5   r:   c                   C   r)   )Nc                 S   s"   g | ]}t d D ]}|| qqS r0   r3   )r-   r   r$   r   r   r   r.   N   s   " z'list_comprehension4.<locals>.<listcomp>r0   r1   r   r   r   r   list_comprehension4M   r5   r=   c                   C      dd t dD S )Nc                 S   s   g | ]}|d  qS r*   r   r,   r   r   r   r.   Q   r/   z'list_comprehension5.<locals>.<listcomp>r0   r<   r   r   r   r   list_comprehension5P      r?   c                   C   r>   )Nc                 S   s   g | ]}d d t |D qS )c                 S      g | ]}|qS r   r   r,   r   r   r   r.   T       z2list_comprehension6.<locals>.<listcomp>.<listcomp>r<   )r-   r$   r   r   r   r.   T   s    z'list_comprehension6.<locals>.<listcomp>   r<   r   r   r   r   list_comprehension6S   r@   rD   c                 C   s   t t| S r   listr3   nr   r   r   list_constructorW      rI   c                   C   s   t  S r   rF   r   r   r   r   list_constructor_emptyZ   s   rL   c                 C   s   t  }|| S r   )rF   append)rH   r$   r   r   r   #list_constructor_empty_but_typeable_   s   
rN   c                 C   *   g }| d t| D ]}| | q|S N*   rM   r3   rH   lir   r   r   list_appende   
   
rV   c                 C   rO   )N      E@rR   rS   r   r   r   list_append_heterogeneousl   rW   rY   c                 C   s:   g }| t|  | |d d  | t| dd |S )Nr   extendr3   rH   rT   r   r   r   list_extends   s
   r^   c                 C   s>   g }| t|  | |d d  | d | dg |S )NrZ   )   rQ   g     ^@r[   r]   r   r   r   list_extend_heterogeneous{   s   
r`   c                 C   s@   t t| }d}t|dkr|t||  7 }t|dks|S Nr   )rF   r3   r   pop)rH   rT   r   r   r   r   	list_pop0   s   rc   c                 C   s   t t| }||}||fS r   )rF   r3   rb   )rH   rU   rT   r   r   r   r   	list_pop1   s   
rd   c                 C   s   t t| }t|S r   rF   r3   r   r]   r   r   r   list_len      rf   c                 C   s\   t t| }d}tt|D ]
}||||  7 }qtt| dD ]
}||||  8 }q!|S ra   re   rH   rT   r   rU   r   r   r   list_getitem   s   ri   c                 C   sz   t t| }d}tt|D ]
}|||  ||< qtt| dD ]
}|||  ||< q!tt|D ]}||| 7 }q2|S ra   re   rh   r   r   r   list_setitem   s   rj   c                 C   s   t t| }||| S r   rE   rH   startstoprT   r   r   r   list_getslice2   s   rn   c                 C   s   t t| }|||| S r   rE   )rH   rl   rm   steprT   r   r   r   list_getslice3   s   rp   c                 C   s.   t t| }t tdd| }||||< |S Nd   rE   )rH   Zn_sourcerl   rm   rT   r   r   r   r   list_setslice2   s   rs   c                 C   sN   t t| }|||| }tt|D ]
}||  d7  < q|||||< |S rq   re   )rH   rl   rm   ro   rT   r   rU   r   r   r   list_setslice3   s   rt   c                 C   s,   t t| }t tdd| ||||< |S rq   rE   )rH   n_srcrl   rm   ro   rT   r   r   r   list_setslice3_arbitrary   s   rv   c                 C   s   t t| }|d d = |S r   rE   r]   r   r   r   list_delslice0      
rw   c                 C   s$   t t| }||d = |d |= |S r   rE   rk   r   r   r   list_delslice1   s   

ry   c                 C   s   t t| }|||= |S r   rE   rk   r   r   r   list_delslice2   rx   rz   c                 C      t t| }|  |S r   )rF   r3   clearr]   r   r   r   
list_clear      r}   c                 C   s&   t t| }| }|d ||fS rP   )rF   r3   copyrM   )rH   rT   llr   r   r   	list_copy   s   
r   c                 C   s2   t t| }d}t|D ]
\}}||| 7 }q|S ra   )rF   r3   	enumerate)rH   rT   r   rU   r   r   r   r   list_iteration   s
   r   c              	   C   sH   t t| }d|v d|v | d |v | |v d|vd|v| d |v| |vfS Nr      rE   r]   r   r   r   list_contains   s   r   c                 C   s   t t| dd}||S Nr   rZ   rF   r3   indexrH   r   rT   r   r   r   list_index1   s   
r   c                 C   s   t t| dd}|||S r   r   )rH   r   rl   rT   r   r   r   list_index2   s   r   c                 C   s   t t| dd}||||S r   r   )rH   r   rl   rm   rT   r   r   r   list_index3   s   r   c                 C   s"   t t| d dd}|| |S )Nr   rZ   )rF   r3   remover   r   r   r   list_remove   s   
r   c                 C   s   t td| }||| |S ra   )rF   r3   insert)rH   posr   rT   r   r   r   list_insert  s   r   c                 C   s*   g }t | D ]	}||d@  q||S )NrC   )r3   rM   count)rH   r   rT   r   r   r   r   
list_count  s   
r   c                 C   r{   r   )rF   r3   reverser]   r   r   r   list_reverse  r~   r   c                 C   s<   t td| }t tdd| }|| }|d |||fS )Nr   rr   rQ   )rF   r3   rM   )mrH   r   r   r   r   r   r   list_add  s
   

r   c                  C   s<   dg} dg}| | }||  }|  d | d | |||fS )Nr          @rC         @rM   )r   r   r'   dr   r   r   list_add_heterogeneous  s   

r   c                 C   s0   t td| }t tdd| }||7 }||fS )Nr   rr   rE   )r   rH   r   r   r   r   r   list_add_inplace"  s   r   c                  C   s$   dg} dg}| |7 } || 7 }| |fS )Nr   r   r   r   r   r   r   list_add_inplace_heterogeneous(  s
   r   c                 C   s   t t| }|| S r   rE   rH   r   r   r   r   r   list_mul/  rg   r   c                 C   s   t t| }|| S r   rE   r   r   r   r   	list_mul23  rg   r   c                 C   s   t t| }||9 }|S r   rE   r   r   r   r   list_mul_inplace7  r~   r   c                 C   s"   t t| }t||rdfS dfS )NTF)rF   r3   bool)rH   r   r   r   r   	list_bool<  s   r   c                 C   s   t | t |kS r   rK   r   r   r   r   
eq_usecase@     r   c                 C   s   t | t |kS r   rK   r   r   r   r   
ne_usecaseC  r   r   c                 C   s   t | t |kS r   rK   r   r   r   r   
gt_usecaseF  r   r   c                 C   s   t | t |kS r   rK   r   r   r   r   
ge_usecaseI  r   r   c                 C   s   t | t |k S r   rK   r   r   r   r   
lt_usecaseL  r   r   c                 C   s   t | t |kS r   rK   r   r   r   r   
le_usecaseO  r   r   c                 C   s8   t t| }|}|d d  }||u ||u||u ||ufS r   rE   )rH   r   r   r'   r   r   r   identity_usecaseR  s   r   c                  C   s,   dg} d| d< d}| D ]}||A }q| |fS )NFTr   r   )rT   r   r   r   r   r   bool_list_usecaseX  s   
r   c                 C   s,   |   }|   }d| d< | | | ||fS )NrX   r   rb   r\   rT   r   r   r$   r   r   r   reflect_simplea  s
   

r   c                 C   s<   |d rg d} |   }|   }d| d< | | | ||fS )Nr   )g      &@g      6@g     @@g      F@rX   r   r   r   r   r   reflect_conditionalh  s   

r   c                 C   s   |  d trP   )rM   ZeroDivisionErrorrT   r   r   r   reflect_exceptionr     
r   c                 C   s   |  |  | |u S r   )rM   rb   )rT   r   r   r   r   reflect_dualv  s   r   c                   @   s  e Zd Zdd Zdd Zdd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d6d7 Zd8d9 Zd:d; Zd<d= Z d>d? Z!d@dA Z"dBdC Z#dDdE Z$dFdG Z%dHdI Z&dJdK Z'dLdM Z(dNdO Z)dPdQ Z*dRdS Z+dTdU Z,dVdW Z-dXdY Z.dZd[ Z/d\d] Z0d^d_ Z1d`da Z2dbdc Z3ddde Z4e56e7j8dfkdgdhdi Z9djdk Z:dldm Z;dndo Z<dpdq Z=drds Z>dtdu Z?dvdw Z@dxdy ZAdzd{ ZBd|d} ZCd~d ZDdS )	TestListsc                 C   s<   t }ttjtjtjf|}| |ddd|ddd d S )Nr   r+   rC   )r&   r   r   int32assertEqualselfpyfunccfuncr   r   r   test_create_list}  s    zTestLists.test_create_listc              
   C   sT   t }ttjtjtjtjtjtjf|}| |dddddd|dddddd d S )Nr   r+   rC      r_      )r(   r   r   r   r   r   r   r   r   test_create_nested_list  s   ,z!TestLists.test_create_nested_listTc                 C   s>   t dd|}dD ]}|r| jn| j}||||| q	d S )NTZnopython)r   rC      F   i  )r   assertPreciseEqualr   )r   r   preciser   rH   eqr   r   r   check_unary_with_size  s
   zTestLists.check_unary_with_sizec                 C      |  t d S r   )r   rI   r   r   r   r   test_constructor     zTestLists.test_constructorc                 C   sz   |    tddt}| tj}|  W d    n1 sw   Y  t|j}| d| | d| | d| d S )NTr   z!Cannot infer the type of variablezlist(undefined)z&For Numba to be able to compile a list)	disable_leak_checkr   rL   assertRaisesr	   TypingErrorstr	exceptionassertIn)r   r   raiseserrmsgr   r   r   test_constructor_empty  s   
z TestLists.test_constructor_emptyc                 C   s`   t ddddgddgt dgg}t}|D ]}tdd	|}||}||}| || qd S )
Nr   g      $@y      ?      @   g      1@g      ,@r0   Tr   )npr   arrayrN   r   r   )r   argsr   argr   expectedgotr   r   r   #test_constructor_empty_but_typeable  s   $z-TestLists.test_constructor_empty_but_typeablec                 C   r   r   )r   rV   r   r   r   r   test_append  r   zTestLists.test_appendc                 C      | j tdd d S NF)r   )r   rY   r   r   r   r   test_append_heterogeneous  r@   z#TestLists.test_append_heterogeneousc                 C   r   r   )r   r^   r   r   r   r   test_extend  r   zTestLists.test_extendc                 C   r   r   )r   r`   r   r   r   r   test_extend_heterogeneous  r@   z#TestLists.test_extend_heterogeneousc                 C   r   r   )r   rc   r   r   r   r   	test_pop0  r   zTestLists.test_pop0c              
   C   sj   t }tdd|}dD ]'}dd|d |d dd| d	 | d fD ]}|||}| |||| q!qd S )
NTr   r_   (   r   r   r+   rZ   rC   )rd   r   r   )r   r   r   rH   rU   r   r   r   r   	test_pop1  s   ,
zTestLists.test_pop1c                 C   s   |    tddt}| t}|dd W d    n1 s w   Y  | t|jd | t}|dd W d    n1 sCw   Y  | t|jd d S )NTr   r   r_   zpop from empty listr   zpop index out of range)r   r   rd   r   
IndexErrorr   r   r   )r   r   cmr   r   r   test_pop_errors  s   zTestLists.test_pop_errorsc                 C   sx   t }tdd|}dD ].}dd|d |d |d dd| d	 | d g	}|D ]}|||d
}| |||d
| q&qd S )NTr   r   r   r   r+   rZ   r   rC   rQ   )r   r   r   )r   r   r   rH   indicesrU   r   r   r   r   test_insert  s   .zTestLists.test_insertc                 C   r   r   )r   rf   r   r   r   r   test_len  r   zTestLists.test_lenc                 C   r   r   )r   ri   r   r   r   r   test_getitem  r   zTestLists.test_getitemc                 C   r   r   )r   rj   r   r   r   r   test_setitem  r   zTestLists.test_setitemc           	   	   C   s   t dd|}ddg}|D ]0}dd|d dd	| d
 | d | g}t||D ]\}}||||}| ||||| q(qd S NTr   r_   r   r   r   r+   rZ   r   rC   r   	itertoolsproductr   )	r   r   r   sizesrH   r   rl   rm   r   r   r   r   check_slicing2  s   &zTestLists.check_slicing2c                 C   r   r   )r   rn   r   r   r   r   test_getslice2  r   zTestLists.test_getslice2c           
   	   C   s   t }tdd|}ddg}t||D ]4\}}dd|d dd	| d
 | d | g}t||D ]\}}|||||}	| ||||||	 q0qd S r   )rs   r   r   r   r   )
r   r   r   r   rH   ru   r   rl   rm   r   r   r   r   test_setslice2  s   &zTestLists.test_setslice2c           
   	   C      t }tdd|}dD ]8}dd|d dd| d	 | d | g}g d
}t|||D ]\}}}|||||}	| ||||||	 q+qd S NTr   r;   r   r   r+   rZ   r   rC   )r   r   rZ   r+   )rp   r   r   r   r   
r   r   r   rH   r   Zstepsrl   rm   ro   r   r   r   r   test_getslice3     &zTestLists.test_getslice3c           
   	   C   r   r   )rt   r   r   r   r   r   r   r   r   test_setslice3  r   zTestLists.test_setslice3c                 C   sz   |    t}tdd|}|ddddd | t}|dddd	d W d    n1 s-w   Y  | d
t|j d S )NTr   r_   r0   r   r+   r   rr   rC   zcannot resize)r   rv   r   r   
ValueErrorr   r   r   r   r   r   r   r   r   r   test_setslice3_resize  s   zTestLists.test_setslice3_resizec                 C   r   r   )r   rw   r   r   r   r   test_delslice0  r   zTestLists.test_delslice0c                 C   r   r   )r   ry   r   r   r   r   test_delslice1  r   zTestLists.test_delslice1c                 C   r   r   )r   rz   r   r   r   r   test_delslice2  r   zTestLists.test_delslice2c                 C   sh   |    t}tdd|}| t}|dddd W d    n1 s$w   Y  | t|jd d S )NTr   r0   r   r+   r   zslice step cannot be zero)r   rp   r   r   r  r   r   r   r  r   r   r   test_invalid_slice  s   zTestLists.test_invalid_slicec                 C   r   r   )r   r   r   r   r   r   test_iteration!  r   zTestLists.test_iterationc                 C   r   r   )r   r   r   r   r   r   test_reverse$  r   zTestLists.test_reversec                 C   r   r   )r   r   r   r   r   r   test_contains'  r   zTestLists.test_containsc                 C   sl   z|| }W n% t y+   | t  ||  W d    Y d S 1 s#w   Y  Y d S w | || | d S r   )r  r   r   )r   r   r   r   r   r   r   r   check_index_result*  s   
&zTestLists.check_index_resultc                 C   s:   |    t}tdd|}dD ]}| ||d|f qd S )NTr   r   r   r_   r0   ir   )r   r   r   r  r   r   r   r   r   r   r   test_index13  s   zTestLists.test_index1c                 C   sx   |    t}tdd|}d}dD ](}dd|d |d |d dd	| d
 | d g	}|D ]}| ||d||f q,qd S NTr   r   r  r   r   r+   rZ   r   rC   )r   r   r   r  )r   r   r   rH   r   r   rl   r   r   r   test_index2:  s   .zTestLists.test_index2c                 C   s   |    t}tdd|}d}dD ]/}dd|d |d |d dd	| d
 | d g	}t||D ]\}}| ||d|||f q0qd S r  )r   r   r   r   r   r  )r   r   r   rH   r   r   rl   rm   r   r   r   test_index3D  s   .zTestLists.test_index3c                 C   sX   t }tdd|}d}| tj| |dddd W d    d S 1 s%w   Y  d S )NTr   zarg "start" must be an Integer.r0   r   invalidr_   r   r   assertRaisesRegexr	   r   r   r   r   msgr   r   r   test_index_exception1N     "zTestLists.test_index_exception1c                 C   sX   t }tdd|}d}| tj| |dddd W d    d S 1 s%w   Y  d S )NTr   zarg "stop" must be an Integer.r0   r   r  r  r  r   r   r   test_index_exception2U  r  zTestLists.test_index_exception2c                 C   s@   t }tdd|}d}dD ]}|||}| |||| qd S )NTr   r   )r   r   r_      )r   r   r   r   r   r   rH   r   r   r   r   r   test_remove\  s   
zTestLists.test_removec                 C   sd   |    t}tdd|}| t}|dd W d    n1 s"w   Y  | t|jd d S )NTr   r0   rQ   zlist.remove(x): x not in list)r   r   r   r   r  r   r   r   r  r   r   r   test_remove_errord  s   zTestLists.test_remove_errorc                 C   s<   t }tdd|}tdD ]}| |d||d| qd S )NTr   r_      )r   r   r3   r   r  r   r   r   
test_countl  s
   zTestLists.test_countc                 C   r   r   )r   r}   r   r   r   r   
test_clearr  r   zTestLists.test_clearc                 C   r   r   )r   r   r   r   r   r   	test_copyu  r   zTestLists.test_copyc                 C   sL   t dd|}g d}t||D ]\}}|||}| |||| qd S )NTr   r   rC   2   ,  r   )r   r   r   r   r   rH   r   r   r   r   	check_addx  s   
zTestLists.check_addc                 C   r   r   )r%  r   r   r   r   r   test_add  r   zTestLists.test_addc                 C   *   t }tdd|}| }| | | d S NTr   )r   r   r   r   r   r   r   r   r   r   test_add_heterogeneous     z TestLists.test_add_heterogeneousc                 C   r   r   )r%  r   r   r   r   r   test_add_inplace  r   zTestLists.test_add_inplacec                 C   r'  r(  )r   r   r   r)  r   r   r   test_add_inplace_heterogeneous  r+  z(TestLists.test_add_inplace_heterogeneousc                 C   sB   t dd|}dD ]}dD ]}|||}| |||| qq	d S )NTr   r"  )r   r+   rC   r   rZ   ir   r   r  r   r   r   	check_mul  s   
zTestLists.check_mulc                 C   r   r   )r/  r   r   r   r   r   test_mul  r   zTestLists.test_mulc                 C   r   r   )r/  r   r   r   r   r   	test_mul2  r   zTestLists.test_mul2c                 C   r   r   )r/  r   r   r   r   r   test_mul_inplace  r   zTestLists.test_mul_inplacel        z,need a 64-bit system to test for MemoryErrorc                 C   s   |    t}tdd|}| t |dd W d    n1 s"w   Y  tjdr:t	d}|
dd | t |dd	 W d    d S 1 sPw   Y  d S )
NTr   r   l           darwinz
libc.dylibz###Please ignore the above error message i.e. can't allocate region. It is in fact the purpose of this test to request more memory than can be provided###
zUTF-8l            )r   r   r   r   MemoryErrorsysplatform
startswithctCDLLZprintfencode)r   r   r   libcr   r   r   test_mul_error  s   
"zTestLists.test_mul_errorc                 C   s8   t }tdd|}dD ]}||}| ||| qd S )NTr   )r   r   rC   )r   r   r   )r   r   r   rH   r   r   r   r   	test_bool  s   zTestLists.test_boolc                    s<   t dddd  t dd fdd}| |dd d S )	NTr   c                 S   s   t | | d fS NrZ   r   )lstr   r   r   inner  s   z*TestLists.test_list_passing.<locals>.innerc                    s   t t| } |S r   rE   r]   r@  r   r   outer  s   z*TestLists.test_list_passing.<locals>.outerr_   )r_   r   r.  )r   rB  r   rA  r   test_list_passing  s
   
zTestLists.test_list_passingc                    sR    fdd}t dd |d |d |d |d |d	 |d
 d S )Nc                    s      |  |  d| f  d S )Nzmismatch for arguments %s)ZassertIsr   r   r   r   r   r   r     s   z#TestLists._test_compare.<locals>.eqTr   )r   r+   rF  )r   r+   rC   rF  )rF  rG  ))r   r+   r   rG  ))      ?r         @rG  ))rH  r   g      @rG  r   )r   r   r   r   rE  r   _test_compare  s   zTestLists._test_comparec                 C   r   r   )rK  r   r   r   r   r   test_eq  r   zTestLists.test_eqc                 C   r   r   )rK  r   r   r   r   r   test_ne  r   zTestLists.test_nec                 C   r   r   )rK  r   r   r   r   r   test_le  r   zTestLists.test_lec                 C   r   r   )rK  r   r   r   r   r   test_lt  r   zTestLists.test_ltc                 C   r   r   )rK  r   r   r   r   r   test_ge  r   zTestLists.test_gec                 C   r   r   )rK  r   r   r   r   r   test_gt  r   zTestLists.test_gtc                 C   s*   t }tdd|}| |d|d d S )NTr   rC   )r   r   r   r   r   r   r   test_identity  s   zTestLists.test_identityc                 C   s&   t }tdd|}| | |  d S r(  )r   r   r   r   r   r   r   test_bool_list  s   zTestLists.test_bool_listN)T)E__name__
__module____qualname__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  r  r  r  r	  r
  r  r  r  r  r  r  r  r  r  r   r!  r%  r&  r*  r,  r-  r/  r0  r1  r2  unittestZ
skipUnlessr5  maxsizer<  r=  rC  rK  rL  rM  rN  rO  rP  rQ  rR  rS  r   r   r   r   r   {  s    
			


	


r   c                   @   sN   e Zd ZdZejdd Zdd Zdd Zdd	 Z	d
d Z
dd Zdd ZdS )TestUnboxingz@
    Test unboxing of Python lists into native Numba lists.
    c                 c   sT    |  t}d V  W d    n1 sw   Y  |d ur(| t|j| d S d S r   )r   	TypeErrorassertRegexr   r   )r   r  r   r   r   r   assert_type_error  s   zTestUnboxing.assert_type_errorc                    s"   t dd  fdd}|S )NTr   c                    s    | } | } || d S r   )r   )r   r   r   rE  r   r   check   s   z'TestUnboxing.check_unary.<locals>.checkrJ  )r   r   r]  r   rE  r   check_unary  s   zTestUnboxing.check_unaryc                 C   s&   |  t}|ddg |ddg d S )Nr   r+                 ?y              @)r^  r   r   r]  r   r   r   test_numbers  s   
zTestUnboxing.test_numbersc                 C   s2   |  t}|ddg |ddg |g d d S )NrF  )rC   r   )r                  @)rC   y              @)r   r   r   )r^  r    r`  r   r   r   test_tuples  s   
zTestUnboxing.test_tuplesc                 C   s   |  t}|dg df d S )Nr   )r+   rC   r   )r^  r"   r`  r   r   r   test_list_inside_tuple     
z#TestUnboxing.test_list_inside_tuplec                 C   s   |  t}|dddgf d S )Nr   r*   )rC   )r^  r#   r`  r   r   r    test_list_of_tuples_inside_tuple  re  z-TestUnboxing.test_list_of_tuples_inside_tuplec                 C   sh  d}t }tdd|}ddg}| | || W d    n1 s#w   Y  | |ddg | | |ddg W d    n1 sFw   Y  | | |dddgf W d    n1 scw   Y  | | |tdddg W d    n1 sw   Y  ddg}| t}|| W d    n1 sw   Y  d	}| t|j|	t
j d S )
Nzcan't unbox heterogeneous listTr   r   g      @rb  r   )r+   rC   zFcan't unbox heterogeneous list: UniTuple({0} x 1) != UniTuple({0} x 2))r   r   r\  r   r   r   rZ  r   r   formatr   intp)r   r  r   r   r?  r   r   r   r   test_errors  s.   

zTestUnboxing.test_errorsN)rT  rU  rV  __doc__
contextlibcontextmanagerr\  r^  ra  rc  rd  rf  rj  r   r   r   r   rY    s    
rY  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S )TestListReflectionzG
    Test reflection of native Numba lists on Python list objects.
    c           
   	   C   s   t dd|}g ddgfg dg dfg}|D ]H\}}t|}t|}|||}| ||) |||}	| |	| | || | |d |u |	d |u  ~~	W d    n1 s[w   Y  qd S )NTr   )rH  r   rI  r           )g      @g      @g      @g       @g      "@r   )r   rF   assertRefCountr   r   )
r   r   r   Zsamplesdestsrcr   r   ZpyresZcresr   r   r   check_reflection;  s"   

z#TestListReflection.check_reflectionc                 C   r   r   )rs  r   r   r   r   r   test_reflect_simpleK  r   z&TestListReflection.test_reflect_simplec                 C   r   r   )rs  r   r   r   r   r   test_reflect_conditionalN  r   z+TestListReflection.test_reflect_conditionalc              	   C   s   t }tdd|}g d}| |* | t || W d   n1 s'w   Y  | |g d W d   dS 1 s?w   Y  dS )ze
        When the function exits with an exception, lists should still be
        reflected.
        Tr   rG  N)r   r+   rC   rQ   )r   r   rp  r   r   r   )r   r   r   rT   r   r   r   test_reflect_exceptionQ  s   
"z)TestListReflection.test_reflect_exceptionc                 C   sb   t }tdd|}g d}|dd }|||}|||}| || | || | || dS )zg
        When the same list object is reflected twice, behaviour should
        be consistent.
        Tr   rG  N)r   r   r   ZassertRefCountEqual)r   r   r   ZpylistZclistr   r   r   r   r   test_reflect_same_list^  s   

z)TestListReflection.test_reflect_same_listc                 C   sD   t ddt}dg}dd |D }|| | dd |D | dS )zP
        When the list wasn't mutated, no reflection should take place.
        Tr   y              )@c                 S      g | ]}t |qS r   idr,   r   r   r   r.   t  r/   z9TestListReflection.test_reflect_clean.<locals>.<listcomp>c                 S   rx  r   ry  r,   r   r   r   r.   v  r/   N)r   r   r   )r   r   rT   Zidsr   r   r   test_reflect_cleanm  s
   z%TestListReflection.test_reflect_cleanN)
rT  rU  rV  rk  rs  rt  ru  rv  rw  r{  r   r   r   r   rn  6  s    rn  c                   @      e Zd Zdd ZdS )ManagedListTestCasec                 C   s8   |  t|t| t||D ]
\}}| || qd S r   )r   r   zipr   )r   expectr   r   r   r   r   r   !assert_list_element_precise_equal{  s   z5ManagedListTestCase.assert_list_element_precise_equalN)rT  rU  rV  r  r   r   r   r   r}  y  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 S )!TestListManagedElementsz,Test list containing objects that need refctc                 C   sd   t dd|}tdtjtdtjg}t|}|| t|}|| | j||d d S )NTr   rC   r_   r  r   )r   r   arangeastyperi  rF   r  )r   r   r   conr  r   r   r   r   _check_element_equal  s   $
z,TestListManagedElements._check_element_equalc                 C      dd }|  | d S )Nc                 S   r   r   r   r  r   r   r   r     r   z=TestListManagedElements.test_reflect_passthru.<locals>.pyfuncr  r   r   r   r   r   test_reflect_passthru  s   z-TestListManagedElements.test_reflect_passthruc                 C   r  )Nc                 S   s   |  tdtj d S )Nr0   )rM   r   r  r  ri  r  r   r   r   r     s   z=TestListManagedElements.test_reflect_appended.<locals>.pyfuncr  r  r   r   r   test_reflect_appended     z-TestListManagedElements.test_reflect_appendedc                 C   r  )Nc                 S   s   t d| d< d S )Nr0   r   r   r  r  r   r   r   r     r@   z<TestListManagedElements.test_reflect_setitem.<locals>.pyfuncr  r  r   r   r   test_reflect_setitem  r  z,TestListManagedElements.test_reflect_setitemc                 C   r  )Nc                 S   s   |    d S r   rb   r  r   r   r   r     rJ   z;TestListManagedElements.test_reflect_popped.<locals>.pyfuncr  r  r   r   r   test_reflect_popped  r  z+TestListManagedElements.test_reflect_poppedc                 C   s   dd }|  | dS )zQmake sure list.insert() doesn't crash for refcounted objects (see #7553)
        c                 S   s   |  dtdtj d S )Nr   r   )r   r   r  r  ri  r  r   r   r   r     s   z;TestListManagedElements.test_reflect_insert.<locals>.pyfuncNr  r  r   r   r   test_reflect_insert  s   z+TestListManagedElements.test_reflect_insertc                 C   4   dd }t dd|}| }| }| j||d d S )Nc                  S   s.   g } t dD ]}| t|tj q| S )Nr$  )r3   rM   r   r  r  ri  r  rU   r   r   r   r     s   z3TestListManagedElements.test_append.<locals>.pyfuncTr   r  r   r  r   r   r   r  r   r   r   r   r        
z#TestListManagedElements.test_appendc                 C   2   dd }t dd|}| }| }| || d S )Nc                  S   sJ   g } t dD ]
}| t| qd}| D ]}|| d|j  7 }q|S )Nr$  ro  r   )r3   rM   r   r  r2   size)r  rU   r'   Zarrr   r   r   r     s   z9TestListManagedElements.test_append_noret.<locals>.pyfuncTr   r   r   r  r   r   r   test_append_noret  s
   	z)TestListManagedElements.test_append_noretc                 C   r  )Nc                  S   s4   g } t dD ]
}| td qtd| d< | S )Nr_   r+   r   r   r3   rM   r   r  r  r   r   r   r     s
   z;TestListManagedElements.test_reassign_refct.<locals>.pyfuncTr   r  r  r  r   r   r   test_reassign_refct     
z+TestListManagedElements.test_reassign_refctc                 C   r  )Nc                  S   s.   g } t dD ]
}| td q| dd S )Nr_   r+   r   r  r  r   r   r   r     s   z6TestListManagedElements.test_get_slice.<locals>.pyfuncTr   r  r  r  r   r   r   test_get_slice  r  z&TestListManagedElements.test_get_slicec                 C   r  )Nc                  S   s:   g } t dD ]
}| td q| dd | dd< | S )Nr_   r+   r   r   rC   r  r  r   r   r   r     s
   z6TestListManagedElements.test_set_slice.<locals>.pyfuncTr   r  r  r  r   r   r   test_set_slice  r  z&TestListManagedElements.test_set_slicec                 C   r  )Nc                  S   sJ   g } t dD ]}| t|d  qt| dkr#|   t| dks| S )N   r   r+   r3   rM   r   r  r   rb   r  r   r   r   r     s   z0TestListManagedElements.test_pop.<locals>.pyfuncTr   r  r  r  r   r   r   test_pop     
z TestListManagedElements.test_popc                 C   r  )Nc                  S   sL   g } t dD ]}| t|d  qt| dkr$| d t| dks| S )Ni  r   r+   r  r  r   r   r   r     s   
z4TestListManagedElements.test_pop_loc.<locals>.pyfuncTr   r  r  r  r   r   r   test_pop_loc  r  z$TestListManagedElements.test_pop_locc                 C   r  )Nc                  S   s4   g } t dD ]}| t|d  q| dd= | S )Nr  r   rC   r0   r  r  r   r   r   r   !  s
   
z6TestListManagedElements.test_del_range.<locals>.pyfuncTr   r  r  r  r   r   r   test_del_range   r  z&TestListManagedElements.test_del_rangec                 C   r  )Nc                  S   s&   g } t dD ]
}| dg|  q| S Nr0   r   )r3   rM   r  r   r   r   r   1  s   z9TestListManagedElements.test_list_of_list.<locals>.pyfuncTr   r  r  r   r   r   test_list_of_list0  s
   z)TestListManagedElements.test_list_of_listN)rT  rU  rV  rk  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r   r   r   r   r    s"    	r  c                    s    fdd}|S )Nc                    sb   |    | t} | g|R i | W d    n1 sw   Y  d}| |t|j d S )Nz-cannot reflect element of reflected container)r   r   rZ  r   r   r   )r   r   kwargsr   Z
expect_msgfnr   r   wrapped@  s   z*expect_reflection_failure.<locals>.wrappedr   )r  r  r   r  r   expect_reflection_failure?  s   r  c                   @   s   e Zd Zdd Zdd Zedd Zedd Zed	d
 Zedd Z	dd Z
dd Zdd Zedd Zdd Zedd Zdd Zdd Zedd Zedd  Zd!d" Zd#S )$TestListOfListc           	      G   sZ   ddl m} ||}|| }||}tdd|}|| }| j||d | j||d d S )Nr   )deepcopyTr   r  )r   r  r   r  )	r   r   r   r  Zexpect_argsr  Z	njit_argsr   r   r   r   r   compile_and_testL  s   
zTestListOfList.compile_and_testc                 C   r  )Nc                  S   s   dd t dD } | S )Nc                 S   s   g | ]}t |gqS r   r  r-   rU   r   r   r   r.   _  r9   zNTestListOfList.test_returning_list_of_list.<locals>.pyfunc.<locals>.<listcomp>r   r<   )r   r   r   r   r   ^  s   z:TestListOfList.test_returning_list_of_list.<locals>.pyfuncr  r  r   r   r   test_returning_list_of_list]  s   z*TestListOfList.test_returning_list_of_listc                 C   s  dd }t dd|}dd tdD dd tdD g}d	d tdD d
gg}dgdhgg}dgddigg}|| | t}|| W d    n1 sPw   Y  | dt|j | t}|| W d    n1 srw   Y  | dt|j | t}|| W d    n1 sw   Y  | dt|j | t}|| W d    n1 sw   Y  | dt|j d S )Nc                 S      | d S Nr   r   r   r   r   r   r   f     z<TestListOfList.test_heterogeneous_list_error.<locals>.pyfuncTr   c                 S      g | ]}t |qS r   r   zerosr  r   r   r   r.   j      z@TestListOfList.test_heterogeneous_list_error.<locals>.<listcomp>r_   c                 S   s   g | ]	}t |d  qS r_  r   Zonesr  r   r   r   r.   k  s    c                 S   r  r   r  r  r   r   r   r.   l  r  rg  r   r   Qreflected list(array(float64, 1d, C)) != reflected list(array(complex128, 1d, C))zDreflected list(array(float64, 1d, C)) != reflected list((int64 x 1))z=reflected list(int64) != reflected list(reflected set(int64))z*Cannot type list element of <class 'dict'>)r   r3   r   rZ  r   r   r   r  )r   r   r   l2l3l4l5r   r   r   r   test_heterogeneous_list_errord  sJ   



z,TestListOfList.test_heterogeneous_list_errorc                 C   sn   dd }t dd|}ddgddgg}d	d
g}t|t|f}t|t|f}||  ||  | || d S )Nc                 S   s   |  | | d  d d S )NrZ   {   r   )l1r  r   r   r   r     s   
z:TestListOfList.test_list_of_list_reflected.<locals>.pyfuncTr   r   r   r+   rC   r   r_   )r   rF   r   )r   r   r   r  r  r  r   r   r   r   test_list_of_list_reflected  s   z*TestListOfList.test_list_of_list_reflectedc                 C   sV   dd }dd t dD dd t dD g}tdd|}||}| ||| d S )	Nc                 S   r  r  r   r   r   r   r   r     r  z6TestListOfList.test_heterogeneous_list.<locals>.pyfuncc                 S   r  r   r  r  r   r   r   r.     r  z:TestListOfList.test_heterogeneous_list.<locals>.<listcomp>r_   c                 S   r  r   r  r  r   r   r   r.     r  Tr   )r3   r   r   )r   r   r  r   Zl1_gotr   r   r   test_heterogeneous_list  s
   $z&TestListOfList.test_heterogeneous_listc                 C   s|   dd }t dgt dd gg}| || | t}| || W d    n1 s.w   Y  | dt|j d S )Nc                 S   s   |   S r   r  r   r   r   r   bar  r  z$TestListOfList.test_c01.<locals>.barr   r0   r_  r  )r   r  r  r   rZ  r   r   r   r   r  rr   r   r   r   test_c01  s   zTestListOfList.test_c01c                 C   d   dd }t dgg}| tj}| || W d    n1 s"w   Y  | dt|j d S )Nc                 S   s   |  |  | S r   r   r   r   r   r   r    r   z$TestListOfList.test_c02.<locals>.barr   z(Invalid use of BoundFunction(list.append)	r   r  r   r	   r   r  r   r   r   r  r   r   r   test_c02  s   zTestListOfList.test_c02c                 C   sx   dd }t dgg}| tj}| || W d    n1 s"w   Y  | dtdt|d t	|j
 d S )Nc                 S   s   | }d|d< |S Nr   r   r   r   fr   r   r   r    s   z$TestListOfList.test_c03.<locals>.barrC   1invalid setitem with value of {} to element of {}r   r   r   r  r   r	   r   r  r   rh  r   r   r   r  r   r   r   test_c03  s   
zTestListOfList.test_c03c                 C   s|   dd }t dgg}| tj}| || W d    n1 s"w   Y  | dtdt|d d t	|j
 d S )Nc                 S   s   | }d|d d< |S r  r   r  r   r   r   r    s   z$TestListOfList.test_c04.<locals>.barrC   r  r0   r   r  r  r   r   r   test_c04  s   zTestListOfList.test_c04c                 C   s.   dd }t dt jgg}| || d S )Nc                 S   s2   | }t dd t dt jD |d d< |S )Nc                 S   rA   r   r   r,   r   r   r   r.     rB   z8TestListOfList.test_c05.<locals>.bar.<locals>.<listcomp>r0   r   )r   r   r  r  ri  r  r   r   r   r    s   *z$TestListOfList.test_c05.<locals>.barrC   )r   r  r  ri  r  r   r  r  r   r   r   test_c05  s   zTestListOfList.test_c05c                 C   r  )Nc                 S   s*   | }t dd t dD |d d< |S )Nc                 S   s   g | ]}|d  qS r  r   r,   r   r   r   r.     r/   z8TestListOfList.test_c06.<locals>.bar.<locals>.<listcomp>r0   r   )r   r   r  r  r   r   r   r    s   "z$TestListOfList.test_c06.<locals>.barrC   invalid setitem with value)	r   r  r   r	   r   r  r   r   r   r  r   r   r   test_c06  s   zTestListOfList.test_c06c                 C   st   |    dd }tdgg}tdd|}| t}|| W d    n1 s*w   Y  | dt|j d S )Nc                 S   r  )Nir   r   r   r   r   r    r  z$TestListOfList.test_c07.<locals>.barrC   Tr   zgetitem out of range)	r   r   r  r   r   r   r   r   r   r   r  r  r   r   r   r   r   test_c07  s   
zTestListOfList.test_c07c                 C   sn   |    dd }g d}tdd|}| t}|| W d    n1 s'w   Y  | dt|j d S )Nc                 S      d| d< | S )Nr   r_   r   r   r   r   r   r       z$TestListOfList.test_c08.<locals>.barrG  Tr   zsetitem out of range)r   r   r   r   r   r   r   r  r   r   r   test_c08  s   
zTestListOfList.test_c08c                 C   s^   dd }g d}|  tj}| || W d    n1 sw   Y  | dt|j d S )Nc                 S   r  )Ny              @r   r   r   r   r   r   r  "  r  z$TestListOfList.test_c09.<locals>.barrG  r  )r   r	   r   r  r   r   r   r  r   r   r   test_c09!  s   zTestListOfList.test_c09c                 C   (   dd }g dg dg}|  || d S )Nc                 S      | d | d | d< | d< | S r  r   r   r   r   r   r  -     z$TestListOfList.test_c10.<locals>.barrG  r   r_   r   r  r  r   r   r   test_c10+     zTestListOfList.test_c10c                 C   r  )Nc                 S   s   | d d d | d d < | S r>  r   r   r   r   r   r  6  s   z$TestListOfList.test_c11.<locals>.barrG  r  r  r  r   r   r   test_c114  r  zTestListOfList.test_c11c                 C   s*   dd }dd t dD }| || d S )Nc                 S   s
   | d= | S r>  r   r   r   r   r   r  >  s   z$TestListOfList.test_c12.<locals>.barc                 S   rA   r   r   r,   r   r   r   r.   B  rB   z+TestListOfList.test_c12.<locals>.<listcomp>r0   )r3   r  r  r   r   r   test_c12=  s   zTestListOfList.test_c12N)rT  rU  rV  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r  J  s4    
0




	



r  c                   @   r|  )Itemc                 C   s   || _ || _d S r   manyscalar)r   r  r  r   r   r   __init__G  s   
zItem.__init__N)rT  rU  rV  r  r   r   r   r   r  F  s    r  c                   @   s   e Zd Zdd Zdd ZdS )	Containerc                 C   s   dd t |D | _d S )Nc                 S   s    g | ]}t |t jgqS r   )r   r  r  float64r  r   r   r   r.   N  s     z&Container.__init__.<locals>.<listcomp>)r3   data)r   rH   r   r   r   r  M  s   zContainer.__init__c                 C   s.   t |D ]}| jt|tjg qd S r   )r3   r  rM   r   r  r  r  )r   rH   rU   r   r   r   moreP  s   zContainer.moreN)rT  rU  rV  r  r  r   r   r   r   r  L  s    r  c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestListAndJitClassesc                 C   s,   dt jd d  fdt jfg}t|t}|S )Nr  r  )r   r  r   r  )r   specJCItemr   r   r   make_jitclass_elementV  s
   z+TestListAndJitClasses.make_jitclass_elementc                 C   s2   dt jt t jd d d di}t|t}|S )Nr  r   )dtype)r   Listr  r   r  )r   r  JCContainerr   r   r   make_jitclass_container^  s   z-TestListAndJitClasses.make_jitclass_containerc                 C   s"   t ||D ]	\}}||| qd S r   )r~  )r   Ztesterr  r   r   r$   r   r   r   assert_list_element_with_testere  s   z5TestListAndJitClasses.assert_list_element_with_testerc           	         s      dd }fdd}tdd|} fddtd	D }t|}t|}||}||}||| ||| d S )
Nc                 S   r  r   r   )Zxsr   r   r   r   l  r  zETestListAndJitClasses.test_jitclass_instance_elements.<locals>.pyfuncc                    s$     | j|j   | j|j d S r   )r   r  r  )r   r$   r   r   r   r   p  s   zATestListAndJitClasses.test_jitclass_instance_elements.<locals>.eqTr   c                    s(   g | ]} t j|d  |d dqS )r   g333333?r  )r   random)r-   rH   )r  r   r   r.   v  s     zITestListAndJitClasses.test_jitclass_instance_elements.<locals>.<listcomp>r_   )r  r   r3   rF   r  )	r   r   r   r   r   Z
expect_argZgot_argZ
expect_resZgot_resr   )r  r   r   test_jitclass_instance_elementsi  s   
z5TestListAndJitClasses.test_jitclass_instance_elementsc                 C   sT   |   }tdd}|dd}| |j|j |d |d | |j|j d S )Nr   rG   rC   )r  r  r  r  r  )r   r  r  r   r   r   r   test_jitclass_containing_list  s   



z3TestListAndJitClasses.test_jitclass_containing_listN)rT  rU  rV  r  r  r  r  r  r   r   r   r   r  U  s    r  c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )TestListInitialValuesz5Tests that lists carry their initial value if presentc                    6   dd  t  fdd}t fdd}|  d S )Nc                 S   r   r   r   r   r   r   r   r    r   z?TestListInitialValues.test_homogeneous_and_literal.<locals>.barc                    sP   | j d u r	dd S  t| tj  | j g d  t| dd dd S )Nc                 S      t | S r   r   r   r   r   r   <lambda>      zTTestListInitialValues.test_homogeneous_and_literal.<locals>.ol_bar.<locals>.<lambda>rG  literal_valueFc                 S      | S r   r   r   r   r   r   r        )initial_value
assertTrue
isinstancer   r  r   hasattrr   r   r   r   ol_bar  s   
zBTestListInitialValues.test_homogeneous_and_literal.<locals>.ol_barc                        g d}  |  d S )NrG  r   r   r  r   r   foo  s   z?TestListInitialValues.test_homogeneous_and_literal.<locals>.foor   r   r   r  r  r   r  r   r   test_homogeneous_and_literal  s   
z2TestListInitialValues.test_homogeneous_and_literalc                    r  )Nc                 S   r   r   r   r   r   r   r   r    r   zQTestListInitialValues.test_heterogeneous_but_castable_to_homogeneous.<locals>.barc                    s:     t| tj  | jd   t| dd dd S )Nr  Fc                 S   r  r   r   r   r   r   r   r    r  zfTestListInitialValues.test_heterogeneous_but_castable_to_homogeneous.<locals>.ol_bar.<locals>.<lambda>)r  r  r   r  r   r  r  r   r   r   r   r    s   zTTestListInitialValues.test_heterogeneous_but_castable_to_homogeneous.<locals>.ol_barc                     r	  )N)r_  r+   rC   r   r   r
  r   r   r    s   zQTestListInitialValues.test_heterogeneous_but_castable_to_homogeneous.<locals>.foor  r  r   r  r   .test_heterogeneous_but_castable_to_homogeneous  s   
zDTestListInitialValues.test_heterogeneous_but_castable_to_homogeneousc                    r  )Nc                 S   r   r   r   r   r   r   r   r    r   z<TestListInitialValues.test_mutation_not_carried.<locals>.barc                    s>   | j d u r	dd S  t| tj  | j g d dd S )Nc                 S   r  r   r  r  r   r   r   r    r   zQTestListInitialValues.test_mutation_not_carried.<locals>.ol_bar.<locals>.<lambda>rG  c                 S   r  r   r   r  r   r   r   r    r  )r  r  r  r   r  r   r  r   r   r   r    s
   
z?TestListInitialValues.test_mutation_not_carried.<locals>.ol_barc                     s   g d} |  d  |  d S )NrG  r   r   r   r
  r   r   r    s   
z<TestListInitialValues.test_mutation_not_carried.<locals>.foor  r  r   r  r   test_mutation_not_carried  s   
z/TestListInitialValues.test_mutation_not_carriedc                    s   t dd }|d ftg dffD ]2\}t dd dd  t fdd	}t  fd
d}|  jd d }| |j| qd S )Nc                  W   r   r   r   rD  r   r   r   nop     zLTestListInitialValues.test_mutation_not_carried_single_function.<locals>.noprG  c                 S   r   r   r   r   r   r   r   baz  r  zLTestListInitialValues.test_mutation_not_carried_single_function.<locals>.bazc                 S   r   r   r   r%   r   r   r   r    r   zLTestListInitialValues.test_mutation_not_carried_single_function.<locals>.barc                    s    fdd}|S )Nc                    s   |   |  d S r   r   r  r  r  r   r   impl     z]TestListInitialValues.test_mutation_not_carried_single_function.<locals>.ol_bar.<locals>.implr   )r%   r  r  r   r   r    s   zOTestListInitialValues.test_mutation_not_carried_single_function.<locals>.ol_barc                     s   g d}  |  |  d | S )NrG  r+   r   r   r
  r   r   r    s   
zLTestListInitialValues.test_mutation_not_carried_single_function.<locals>.foor   )r   r   r   
signaturesr   r  )r   r  Zivr  r  largr   )r  r  r  r   )test_mutation_not_carried_single_function  s   

z?TestListInitialValues.test_mutation_not_carried_single_functionc                    sR   t dd  t  fdd}|   jd d }| |jd  | |jjd  d S )Nc                 S   r   r   r   r   r   r   r   r    r  z9TestListInitialValues.test_list_of_list_ctor.<locals>.barc                     s   g dg dg}  |  d S )N)r   r+   rC   r   r_   )r   r+   rC   r   r   r   r   r
  r   r   r    s   z9TestListInitialValues.test_list_of_list_ctor.<locals>.foor   )r   r  r   r  r  )r   r  r  r   r
  r   test_list_of_list_ctor  s   
z,TestListInitialValues.test_list_of_list_ctorN)	rT  rU  rV  rk  r  r  r  r  r  r   r   r   r   r    s    #r  c                   @   s   e 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!S )"TestLiteralListsc                 C   s   t dd }|  d S )Nc                  S   s   ddg} d S )Nr   r   r   r   r   r   r   r    s   z0TestLiteralLists.test_basic_compile.<locals>.foo)r   r   r  r   r   r   test_basic_compile  s   

z#TestLiteralLists.test_basic_compilec                    r  )Nc                 S   r   r   r   r   r   r   r   r    r   z<TestLiteralLists.test_literal_value_passthrough.<locals>.barc                    s     t| tj | j}  t|t  |d td  |d td  |d ttj	dd  |d tj
tjdg dd	   t|d
 tj  |d
 jd td  |d
 jd td dd S )Nr   r   r   r+   CrC   FrG  )	reflectedr  r   catr0   c                 S   r  r   r   r   r   r   r   r     r  zQTestLiteralLists.test_literal_value_passthrough.<locals>.ol_bar.<locals>.<lambda>)r  r  r   LiteralListr  rF   r   literalArrayr  r  ri  )r   lvr   r   r   r    s   z?TestLiteralLists.test_literal_value_passthrough.<locals>.ol_barc                     s4   g d} ddg}t d}dd|| |g} | d S )NrG  r#  r0   r_   r   r   r  )ZotherhomogeneouslistZotherheterogeneouslistr  rT   r
  r   r   r  "  s
   
z<TestLiteralLists.test_literal_value_passthrough.<locals>.foor  r  r   r  r   test_literal_value_passthrough  s   
z/TestLiteralLists.test_literal_value_passthroughc                    r  )Nc                 S   r   r   r   r   r   r   r   r  .  r   zETestLiteralLists.test_literal_value_involved_passthrough.<locals>.barc              
      s    t| tj | j}tdtdtdttjddi}t|}tdttdtdtj	tj
tjddid|gtd	td
tdtjtjddi} fdd  || dd S )NghrU   r   r!  r   r  )r  r   r+   r'   F)r"  c                    s0  t | tjr!t |tjr!t| j|jD ]\}} | j|j qd S t | tr<t |tr<t| |D ]	\}} || q0d S t | tjrht |tjrht| j |j D ]\\}}\}} ||  || qSd S t | trt |trt|  | D ]\\}}\}} ||  || q{d S 	| | d S r   )
r  r   r$  r~  r  rF   LiteralStrKeyDictitemsdictr   )r   r   rU   jZkiviZkjZvj)
check_samer   r   r   r0  D  s:   





"
z\TestLiteralLists.test_literal_value_involved_passthrough.<locals>.ol_bar.<locals>.check_samec                 S   r  r   r   r   r   r   r   r  [  r  zZTestLiteralLists.test_literal_value_involved_passthrough.<locals>.ol_bar.<locals>.<lambda>)r  r  r   r+  r  r%  r&  r  r$  ZDictTypeZunicode_typeri  r  Z
complex128)r   ZdlvZinner_literalZ
inner_dictZouter_literalr   )r0  r   r  1  s2   

zHTestLiteralLists.test_literal_value_involved_passthrough.<locals>.ol_barc                     s4   ddddidt ddgdg dd	}  |  d S )
Nr   r   r  r*  r_   )r)  rU   r+   )r_  rb                @)r   r   r'   r  r   r
  r   r   r  ]  s   zETestLiteralLists.test_literal_value_involved_passthrough.<locals>.foor  r  r   r  r   'test_literal_value_involved_passthrough,  s   +
z8TestLiteralLists.test_literal_value_involved_passthroughc              
   C   s   dd }dd }dd }dd }d	d
 }dd }dd }dd }dd }	dd }
|||||||||	|
f
}|D ]>}|  |j. | tj}t|  W d    n1 sUw   Y  d}| |t|j W d    n1 sow   Y  q6d S )Nc                  S   s   ddg} d| d< d S )Nr   r   r   r   r   r   r   r   r   staticsetitemj  r  z=TestLiteralLists.test_mutation_failure.<locals>.staticsetitemc                  S   s   ddg} | d= d S Nr   r   r   r   r   r   r   r   delitemn  s   
z7TestLiteralLists.test_mutation_failure.<locals>.delitemc                  S   s   ddg} |  d d S )Nr   r   rb  r   r   r   r   r   rM   r     z6TestLiteralLists.test_mutation_failure.<locals>.appendc                  S   s   ddg} |  ddg d S )Nr   r   rb  r1  )r\   r   r   r   r   r\   v  s   z6TestLiteralLists.test_mutation_failure.<locals>.extendc                  S   s   ddg} |  dd d S )Nr   r   r   rb  )r   r   r   r   r   r   z  s   z6TestLiteralLists.test_mutation_failure.<locals>.insertc                  S      ddg} |  d d S Nr   r   )r   r   r   r   r   r   ~  r6  z6TestLiteralLists.test_mutation_failure.<locals>.removec                  S      ddg} |    d S r8  r  r   r   r   r   rb     r  z3TestLiteralLists.test_mutation_failure.<locals>.popc                  S   r9  r8  )r|   r   r   r   r   r|     r  z5TestLiteralLists.test_mutation_failure.<locals>.clearc                  S   r9  r8  )sortr   r   r   r   r:    r  z4TestLiteralLists.test_mutation_failure.<locals>.sortc                  S   r9  r8  )r   r   r   r   r   r     r  z7TestLiteralLists.test_mutation_failure.<locals>.reverseCannot mutate a literal list)	ZsubTestrT  r   r	   r   r   r   r   r   )r   r3  r5  rM   r\   r   r   rb   r|   r:  r   Zillegalstestr   r  r   r   r   test_mutation_failureh  s.   z&TestLiteralLists.test_mutation_failurec                 C   "   t dd }| | |  d S )Nc                  S   s*   g d} g }dD ]
}| | | q|S )Nr   r   r   r+   r   rC   r   r   r   r_   r'   abc)rM   r   rT   r  r   r   r   r   r    s
   z(TestLiteralLists.test_count.<locals>.foor   r   Zpy_funcr  r   r   r   r       
zTestLiteralLists.test_countc                 C   r>  )Nc                  S   s   g d} t | S )Nr?  r   r   r   r   r   r       z&TestLiteralLists.test_len.<locals>.foorB  r  r   r   r   r        
zTestLiteralLists.test_lenc                 C   r>  )Nc                  S   s,   g d} g }t dD ]	}||| v  q
|S )Nr?  )r   r   r+   r   )r   rM   rA  r   r   r   r    s
   z+TestLiteralLists.test_contains.<locals>.foorB  r  r   r   r   r
    rC  zTestLiteralLists.test_containsc                 C   Z   t dd }| tj}|d W d    n1 sw   Y  d}| |t|j d S )Nc                 S   s   ddg}||  S r8  r   r   rT   r   r   r   r    rD  z*TestLiteralLists.test_getitem.<locals>.foor   $Cannot __getitem__ on a literal listr   r   r	   r   r   r   r   r   r  r   r  r   r   r   r        

zTestLiteralLists.test_getitemc                 C   r>  )Nc                  S   s   ddg} | d | d fS r4  r   r   r   r   r   r    s   z0TestLiteralLists.test_staticgetitem.<locals>.foorB  r  r   r   r   test_staticgetitem  s   
z#TestLiteralLists.test_staticgetitemc                 C   X   t dd }| tj}|  W d    n1 sw   Y  d}| |t|j d S )Nc                  S   s   g d} | d d S )N)r   r   r   r+   r   r   r   r   r   r       z6TestLiteralLists.test_staticgetitem_slice.<locals>.foorH  rI  rJ  r   r   r   test_staticgetitem_slice  s   
z)TestLiteralLists.test_staticgetitem_slicec                 C   rF  )Nc                 S   s   ddg}d|| < d S )Nr   r   r   r   rG  r   r   r   r    rN  z*TestLiteralLists.test_setitem.<locals>.foor   r;  rI  rJ  r   r   r   r     rK  zTestLiteralLists.test_setitemc                 C   s0   t dd }dD ]}| |||| qd S )Nc                 S   s,   | d dkrddg}|d S ddg}|d S )Nr   rC   r   r   r+   r   r   rG  r   r   r   r    s
   z(TestLiteralLists.test_unify.<locals>.foo)irr   rB  )r   r  r   r   r   r   
test_unify  s
   
zTestLiteralLists.test_unifyc                 C   rF  )Nc                 S   s:   | d dkrg d}nddg}|d |d |d |d fS )Nr   rC   )r   r   rb  r   r+   r   r   rG  r   r   r   r    s   
z,TestLiteralLists.test_not_unify.<locals>.foorr   zCannot unify LiteralListrI  rJ  r   r   r   test_not_unify  s   

zTestLiteralLists.test_not_unifyc                 C   rM  )Nc                  S   r7  r8  )r   r   r   r   r   r    s   z(TestLiteralLists.test_index.<locals>.fooz+list.index is unsupported for literal listsrI  rJ  r   r   r   
test_index  s   
zTestLiteralLists.test_indexc                 C   s"   t dd }| | |  d S )Nc                  S   s   ddg  } | d | d fS r4  )r   r   r   r   r   r    s   z'TestLiteralLists.test_copy.<locals>.foorB  r  r   r   r   r!    rE  zTestLiteralLists.test_copyc                    r  )Nc                 S   r   r   r   r   r   r   r   r    r   z3TestLiteralLists.test_tuple_not_in_mro.<locals>.barc                    s,     t| tj  t| tj dd S )Nc                 S   s   dS )N.r   r   r   r   r   r  !  r  zHTestLiteralLists.test_tuple_not_in_mro.<locals>.ol_bar.<locals>.<lambda>)ZassertFalser  r   Z	BaseTupler  r$  r   r   r   r   r    s   z6TestLiteralLists.test_tuple_not_in_mro.<locals>.ol_barc                     s   ddg}  |  d S r8  r   r   r
  r   r   r  #  rN  z3TestLiteralLists.test_tuple_not_in_mro.<locals>.foor  r  r   r  r   test_tuple_not_in_mro  s   
z&TestLiteralLists.test_tuple_not_in_mroN)rT  rU  rV  r   r(  r2  r=  r  r   r
  r   rL  rO  r   rP  rQ  rR  r!  rS  r   r   r   r   r    s"    <4	r  __main__)kcollectionsr   rl  r   r7   r5  ctypesr8  numpyr   Znumbar   r   r   r   r   rW  Z
numba.corer   r	   Znumba.tests.supportr
   r   Znumba.experimentalr   Znumba.core.extendingr   r   r   r   r    r"   r#   r&   r(   r4   r6   r:   r=   r?   rD   rI   rL   rN   rV   rY   r^   r`   rc   rd   rf   ri   rj   rn   rp   rs   rt   rv   rw   ry   rz   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   r   r   r   r   r   r   r   rY  rn  r}  r  r  r  objectr  r  r  r  r  rT  mainr   r   r   r   <module>   s    
		
	
	
  yDC ? }	8x  
(