o
    1&iC                     @   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 d dl
mZ d dl
mZ dd	iZd
d	i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 G d+d, d,eeZ!e"d-kre#  dS dS ).    N)jitnjit)errorstypes)typeof)TestCaseMemoryLeakMixin)no_pyobj_flags)force_pyobj_flagsforceobjTZnopythonc                 C   s   | \}}}|||fS N )labcr   r   KC:\wamp64\www\opt\env\Lib\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_small-   r*   r+   c                  C   r&   )N)r(   r"   r   r$   r   r   r   r   r   unpack_tuple_too_large2   r*   r,   c                  C   r&   )N)r(   y              @r   r   r   r   r   $unpack_heterogeneous_tuple_too_small7   r*   r-   c                  C   r&   )N)r(         @              @r$   r   r   r   r   r   $unpack_heterogeneous_tuple_too_large<   r*   r0   c                  C   r&   )N)r(   r.   r/   r   r   r   r   r   unpack_heterogeneous_tupleA   r*   r1   c                  C   s   d\} \}}| | | S )N)r(   )r.   r/   r   r   r   r   r   !unpack_nested_heterogeneous_tupleF   r   r2   c                 C   s   | \}}||fS r   r   )seqr   r   r   r   r   unpack_arbitraryK   s   r4   c                  C   s,   t d} t d}|| f}|\}}||fS )Nr(   r"   npzeros)r   r   tupalphabetar   r   r   
unpack_nrtP   s
   

r;   c                 C   s(   | |f }\}}|\}}|| | | S r   r   )r   r   r   r   r   der   r   r   chained_unpack_assign1X   s   r>   c                 C   s   | dkr	|| } }| |fS )Nr   r   )r   r   r   r   r   conditional_swap_   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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/d0 Zefd1d2Zd3d4 Zd5d6 Zd7d8 Z d9d: Z!d;d< Z"d=S )>
TestUnpackc                 C   s   t |}| | |  d S r   )r   assertPreciseEqualselfpyfunccfuncr   r   r   check_nullary_npmh   s   zTestUnpack.check_nullary_npmc                 C   s"   t dd|}| | |  d S )NTr   )r   rA   rB   r   r   r   check_nullary_objmodel   s   z TestUnpack.check_nullary_objmodec                 C   s2   t }tdd|}g d}| |||| d S )NTrG   r'   )r   r   assertEqual)rC   rD   rE   r   r   r   r   test_unpack_listp   s   zTestUnpack.test_unpack_listc                 C   sP   t }ttjtjdddfdd|}tjddtj}| |||| d S )Nr   CZdtypendimZlayoutTrG   r'   r   )	r   r   r   Arrayint32r6   r7   astyperA   rC   rD   rE   r   r   r   r   test_unpack_shapev   s   zTestUnpack.test_unpack_shapec                 C   sL   t }ttjtjdddf|}tjddtj}| |||| d S )Nr   rK   rL   r'   r   )	r   r   r   rN   rO   r6   r7   rP   rA   rQ   r   r   r   test_unpack_shape_npm}   s   z TestUnpack.test_unpack_shape_npmc                 C      |  t d S r   )rH   r    rC   r   r   r   test_unpack_range      zTestUnpack.test_unpack_rangec                 C   rT   r   )rF   r    rU   r   r   r   test_unpack_range_npm   rW   z TestUnpack.test_unpack_range_npmc                 C   rT   r   )rH   r)   rU   r   r   r   test_unpack_tuple   rW   zTestUnpack.test_unpack_tuplec                 C   rT   r   )rF   r)   rU   r   r   r   test_unpack_tuple_npm   rW   z TestUnpack.test_unpack_tuple_npmc                 C   rT   r   )rH   r1   rU   r   r   r   test_unpack_heterogeneous_tuple   rW   z*TestUnpack.test_unpack_heterogeneous_tuplec                 C   rT   r   )rF   r1   rU   r   r   r   #test_unpack_heterogeneous_tuple_npm   rW   z.TestUnpack.test_unpack_heterogeneous_tuple_npmc                 C   rT   r   )rH   r2   rU   r   r   r   &test_unpack_nested_heterogeneous_tuple   rW   z1TestUnpack.test_unpack_nested_heterogeneous_tuplec                 C   rT   r   )rF   r2   rU   r   r   r   *test_unpack_nested_heterogeneous_tuple_npm   rW   z5TestUnpack.test_unpack_nested_heterogeneous_tuple_npmc                 C   s<   t }ttjtjffi ||}d}| || ||  d S )N)r$      )r>   r   r   rO   rA   )rC   flagsrD   rE   argsr   r   r   test_chained_unpack_assign   s   z%TestUnpack.test_chained_unpack_assignc                 C   s   | j td d S )N)r`   )rb   r	   rU   r   r   r   test_chained_unpack_assign_npm      z)TestUnpack.test_chained_unpack_assign_npmc                 C   sH   |  | tdi ||}|  W d    d S 1 sw   Y  d S )Nr   )r   )assertRaisesr   )rC   rD   r`   excrE   r   r   r   check_unpack_error   s   "zTestUnpack.check_unpack_errorc                 C      |  t |  t d S r   )rg   r+   r-   rU   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   )rg   r+   r	   r   TypingErrorr-   rU   r   r   r   test_unpack_tuple_too_small_npm      z*TestUnpack.test_unpack_tuple_too_small_npmc                 C   rh   r   )rg   r,   r0   rU   r   r   r   test_unpack_tuple_too_large   rj   z&TestUnpack.test_unpack_tuple_too_largec                 C   rk   r   )rg   r,   r	   r   rl   r0   rU   r   r   r   test_unpack_tuple_too_large_npm   rn   z*TestUnpack.test_unpack_tuple_too_large_npmc                 C   rT   r   )rg   r#   rU   r   r   r   test_unpack_range_too_small   rW   z&TestUnpack.test_unpack_range_too_smallc                 C      |  tt d S r   )rg   r#   r	   rU   r   r   r   test_unpack_range_too_small_npm   rd   z*TestUnpack.test_unpack_range_too_small_npmc                 C   rT   r   )rg   r%   rU   r   r   r   test_unpack_range_too_large   rW   z&TestUnpack.test_unpack_range_too_largec                 C   rr   r   )rg   r%   r	   rU   r   r   r   test_unpack_range_too_large_npm   rd   z*TestUnpack.test_unpack_range_too_large_npmc                 C   sD   t tjtjffi |t}| |ddd | |ddd d S )Nr$   r_   )r_   r$   r   )r   r_   )r   r   rO   r?   rA   )rC   r`   rE   r   r   r   check_conditional_swap   s   z!TestUnpack.check_conditional_swapc                 C   s   |    d S r   )rv   rU   r   r   r   test_conditional_swap   s   z TestUnpack.test_conditional_swapc                 C   rT   r   )rv   r	   rU   r   r   r   test_conditional_swap_npm   rW   z$TestUnpack.test_conditional_swap_npmc                 C   sH   t dd tdD }t|}t}t|f|}| |||| d S )Nc                 s   s    | ]
}t |d  V  qdS )r(   Nr5   ).0ir   r   r   	<genexpr>   s    z9TestUnpack.test_unpack_tuple_of_arrays.<locals>.<genexpr>r"   )tupler   r   r4   r   rA   )rC   r8   ZtuptyrD   rE   r   r   r   test_unpack_tuple_of_arrays   s
   z&TestUnpack.test_unpack_tuple_of_arraysc                 C   s$   t }td|}| | |  d S )Nr   )r;   r   rA   rB   r   r   r   test_unpack_nrt   s   zTestUnpack.test_unpack_nrtc                 C   sV   t }| tj}ttjf| W d    n1 sw   Y  | dt|j	 d S )Nzfailed to unpack int32)
r4   re   r   rl   r   r   rO   ZassertInstr	exception)rC   rD   Zraisesr   r   r   test_invalid_unpack   s
   zTestUnpack.test_invalid_unpackN)#__name__
__module____qualname__rF   rH   rJ   rR   rS   rV   rX   rY   rZ   r[   r\   r]   r^   r
   rb   rc   
ValueErrorrg   ri   rm   ro   rp   rq   rs   rt   ru   rv   rw   rx   r}   r~   r   r   r   r   r   r@   f   sB    
r@   __main__)$numpyr6   ZunittestZnumbar   r   Z
numba.corer   r   r   Znumba.tests.supportr   r   r	   Znullary_no_pyobj_flagsr
   Znullary_force_pyobj_flagsr   r   r    r#   r%   r)   r+   r,   r-   r0   r1   r2   r4   r;   r>   r?   r@   r   mainr   r   r   r   <module>   s>     