o
    it                     @   s  d dl 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mZmZ e Zde_e Zde_e Zd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$G d'd( d(eeZ%e&d)kre'  dS dS )*    N)compile_isolatedFlags)errorstypes)typeof)TestCaseMemoryLeakMixintagTc                 C   s   | \}}}|||fS N )labcr   r   o/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/tests/test_unpack_sequence.pyunpack_list   s   

r   c                 C   s   | j \}}}|| | S r
   shape)r   xyzr   r   r   unpack_shape      r   c                  C      t d\} }}| | | S )N   ranger   r   r   r   r   r   unpack_range      r   c                  C   r   )N   r   r   r   r   r   unpack_range_too_small"   r   r!   c                  C   r   )N   r   r   r   r   r   unpack_range_too_large'   r   r#   c                  C      d\} }}| | | S )N   r    r   r   r   r   r   r   unpack_tuple,      
r'   c                  C   r$   )N)r&   r    r   r   r   r   r   unpack_tuple_too_small1   r(   r)   c                  C   r$   )N)r&   r    r   r"   r   r   r   r   r   unpack_tuple_too_large6   r(   r*   c                  C   r$   )N)r&   y              @r   r   r   r   r   $unpack_heterogeneous_tuple_too_small;   r(   r+   c                  C   r$   )N)r&         @              @r"   r   r   r   r   r   $unpack_heterogeneous_tuple_too_large@   r(   r.   c                  C   r$   )N)r&   r,   r-   r   r   r   r   r   unpack_heterogeneous_tupleE   r(   r/   c                  C   s   d\} \}}| | | S )N)r&   )r,   r-   r   r   r   r   r   !unpack_nested_heterogeneous_tupleJ   r   r0   c                 C   s   | \}}||fS r
   r   )seqr   r   r   r   r   unpack_arbitraryO   s   r2   c                  C   s,   t d} t d}|| f}|\}}||fS )Nr&   r    npzeros)r   r   tupalphabetar   r   r   
unpack_nrtT   s
   

r9   c                 C   s(   | |f }\}}|\}}|| | | S r
   r   )r   r   r   r   r   der   r   r   chained_unpack_assign1\   s   r<   c                 C   s   | dkr	|| } }| |fS )Nr   r   )r   r   r   r   r   conditional_swapc   s   
r=   c                   @   s  e Zd Zdd ZefddZdd ZefddZd	d
 ZefddZ	dd Z
efddZdd ZefddZdd ZefddZdd ZeefddZdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zefd-d.Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Z d9S ):
TestUnpackc                 C   s8   t }t|dtd}|j}g d}| |||| d S )Nr   flagsr%   )r   r   force_pyobj_flagsentry_pointassertEqual)selfpyfunccrcfuncr   r   r   r   test_unpack_listl   s
   zTestUnpack.test_unpack_listc                 C   sT   t }t|tjtjdddg|d}|j}tjddtj}| 	|||| d S )Nr   C)ZdtypendimZlayoutr?   r%   r   )
r   r   r   ZArrayint32rB   r4   r5   ZastypeassertPreciseEqual)rD   r@   rE   rF   rG   r   r   r   r   test_unpack_shapes   s   zTestUnpack.test_unpack_shapec                 C      | j td d S Nr?   )rM   no_pyobj_flagsrD   r   r   r   test_unpack_shape_npm}      z TestUnpack.test_unpack_shape_npmc                 C      |  t| d S r
   )run_nullary_funcr   rD   r@   r   r   r   test_unpack_range   rS   zTestUnpack.test_unpack_rangec                 C   rN   rO   )rW   rP   rQ   r   r   r   test_unpack_range_npm   rS   z TestUnpack.test_unpack_range_npmc                 C   rT   r
   )rU   r'   rV   r   r   r   test_unpack_tuple   rS   zTestUnpack.test_unpack_tuplec                 C   rN   rO   )rY   rP   rQ   r   r   r   test_unpack_tuple_npm   rS   z TestUnpack.test_unpack_tuple_npmc                 C   rT   r
   )rU   r/   rV   r   r   r   test_unpack_heterogeneous_tuple   rS   z*TestUnpack.test_unpack_heterogeneous_tuplec                 C   rN   rO   )r[   rP   rQ   r   r   r   #test_unpack_heterogeneous_tuple_npm   rS   z.TestUnpack.test_unpack_heterogeneous_tuple_npmc                 C   rT   r
   )rU   r0   rV   r   r   r   &test_unpack_nested_heterogeneous_tuple   rS   z1TestUnpack.test_unpack_nested_heterogeneous_tuplec                 C   rN   rO   )r]   rP   rQ   r   r   r   *test_unpack_nested_heterogeneous_tuple_npm   rS   z5TestUnpack.test_unpack_nested_heterogeneous_tuple_npmc                 C   s<   t }t|tjtjg|d}|j}d}| || ||  d S )Nr?   )r"      )r<   r   r   rK   rB   rL   )rD   r@   rE   rF   rG   argsr   r   r   test_chained_unpack_assign   s   z%TestUnpack.test_chained_unpack_assignc                 C   rN   rO   )ra   rP   rQ   r   r   r   test_chained_unpack_assign_npm   rS   z)TestUnpack.test_chained_unpack_assign_npmc                 C   sJ   |  | t|d|d}|j}|  W d    d S 1 sw   Y  d S Nr   r?   )assertRaisesr   rB   )rD   rE   r@   excrF   rG   r   r   r   check_unpack_error   s
   "zTestUnpack.check_unpack_errorc                 C      |  t |  t d S r
   )rf   r)   r+   rQ   r   r   r   test_unpack_tuple_too_small      
z&TestUnpack.test_unpack_tuple_too_smallc                 C   $   |  tttj |  tttj d S r
   )rf   r)   rP   r   TypingErrorr+   rQ   r   r   r   test_unpack_tuple_too_small_npm      z*TestUnpack.test_unpack_tuple_too_small_npmc                 C   rg   r
   )rf   r*   r.   rQ   r   r   r   test_unpack_tuple_too_large   ri   z&TestUnpack.test_unpack_tuple_too_largec                 C   rj   r
   )rf   r*   rP   r   rk   r.   rQ   r   r   r   test_unpack_tuple_too_large_npm   rm   z*TestUnpack.test_unpack_tuple_too_large_npmc                 C      |  t d S r
   )rf   r!   rQ   r   r   r   test_unpack_range_too_small      z&TestUnpack.test_unpack_range_too_smallc                 C      |  tt d S r
   )rf   r!   rP   rQ   r   r   r   test_unpack_range_too_small_npm   rS   z*TestUnpack.test_unpack_range_too_small_npmc                 C   rp   r
   )rf   r#   rQ   r   r   r   test_unpack_range_too_large   rr   z&TestUnpack.test_unpack_range_too_largec                 C   rs   r
   )rf   r#   rP   rQ   r   r   r   test_unpack_range_too_large_npm   rS   z*TestUnpack.test_unpack_range_too_large_npmc                 C   sD   t ttjtjf|d}|j}| |ddd | |ddd d S )Nr?   r"   r_   )r_   r"   r   )r   r_   )r   r=   r   rK   rB   rL   )rD   r@   rF   rG   r   r   r   check_conditional_swap   s   z!TestUnpack.check_conditional_swapc                 C   s   |    d S r
   )rw   rQ   r   r   r   test_conditional_swap   s   z TestUnpack.test_conditional_swapc                 C   rp   r
   )rw   rP   rQ   r   r   r   test_conditional_swap_npm   rr   z$TestUnpack.test_conditional_swap_npmc                 C   sP   t dd tdD }t|}t}t||ftd}|j}| |||| d S )Nc                 s   s    | ]
}t |d  V  qdS )r&   Nr3   ).0ir   r   r   	<genexpr>   s    z9TestUnpack.test_unpack_tuple_of_arrays.<locals>.<genexpr>r    r?   )tupler   r   r2   r   rP   rB   rL   )rD   r6   ZtuptyrE   rF   rG   r   r   r   test_unpack_tuple_of_arrays   s   z&TestUnpack.test_unpack_tuple_of_arraysc                 C   s,   t }t|dtd}|j}| | |  d S rc   )r9   r   rP   rB   rL   )rD   rE   rF   rG   r   r   r   test_unpack_nrt   s   zTestUnpack.test_unpack_nrtc                 C   sX   t }| tj}t|tjftd W d    n1 sw   Y  | dt	|j
 d S )Nr?   zfailed to unpack int32)r2   rd   r   rk   r   r   rK   rP   ZassertInstr	exception)rD   rE   Zraisesr   r   r   test_invalid_unpack   s
   zTestUnpack.test_invalid_unpackN)!__name__
__module____qualname__rH   rA   rM   rR   rW   rX   rY   rZ   r[   r\   r]   r^   ra   rb   
ValueErrorrf   rh   rl   rn   ro   rq   rt   ru   rv   rw   rx   ry   r~   r   r   r   r   r   r   r>   j   s:    
	r>   __main__)(numpyr4   ZunittestZnumba.core.compilerr   r   Z
numba.corer   r   Znumbar   Znumba.tests.supportr   r   r	   Zenable_pyobj_flagsZenable_pyobjectrA   Zforce_pyobjectrP   Znrtr   r   r   r!   r#   r'   r)   r*   r+   r.   r/   r0   r2   r9   r<   r=   r>   r   mainr   r   r   r   <module>   sB     