
    xKgY                        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 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z  G d dee      Z!e"dk(  r ejF                          yy)    N)jitnjit)errorstypes)typeof)TestCaseMemoryLeakMixin)no_pyobj_flags)force_pyobj_flagsforceobjTnopythonc                     | \  }}}|||fS N )labcs       d/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_unpack_sequence.pyunpack_listr      s    GAq!q!9    c                 2    | j                   \  }}}||z   |z   S r   shape)r   xyzs       r   unpack_shaper      s    ggGAq!q519r   c                  0    t        d      \  } }}| |z   |z   S )N   ranger   r   r   s      r   unpack_ranger$          AhGAq!q519r   c                  0    t        d      \  } }}| |z   |z   S )N   r!   r#   s      r   unpack_range_too_smallr(      r%   r   c                  0    t        d      \  } }}| |z   |z   S )N   r!   r#   s      r   unpack_range_too_larger+   #   r%   r   c                      d\  } }}| |z   |z   S )N   r'   r    r   r#   s      r   unpack_tupler/   (       GAq!q519r   c                      d\  } }}| |z   |z   S )N)r.   r'   r   r#   s      r   unpack_tuple_too_smallr2   -   s    GAq!q519r   c                      d\  } }}| |z   |z   S )N)r.   r'   r    r*   r   r#   s      r   unpack_tuple_too_larger4   2       GAq!q519r   c                      d\  } }}| |z   |z   S )N)r.   y              @r   r#   s      r   $unpack_heterogeneous_tuple_too_smallr7   7   r0   r   c                      d\  } }}| |z   |z   S )N)r.         @              @r*   r   r#   s      r   $unpack_heterogeneous_tuple_too_larger;   <   s    GAq!q519r   c                      d\  } }}| |z   |z   S )N)r.   r9   r:   r   r#   s      r   unpack_heterogeneous_tupler=   A   r5   r   c                  "    d\  } \  }}| |z   |z   S )N)r.   )r9   r:   r   r#   s      r   !unpack_nested_heterogeneous_tupler?   F   s    IAv1q519r   c                     | \  }}||fS r   r   )seqr   r   s      r   unpack_arbitraryrB   K   s    DAqa4Kr   c                  p    t        j                  d      } t        j                  d      }|| f}|\  }}||fS )Nr.   r'   npzeros)r   r   tupalphabetas        r   
unpack_nrtrJ   P   s8    
A
A
Q$CKE4$;r   c                 4    | |fx}\  }}|\  }}||z   |z   |z   S r   r   )r   r   r   r   r   des          r   chained_unpack_assign1rN   X   s/    QAAFQq519q=r   c                     | dkD  r|| }} | |fS )Nr   r   )r   r   s     r   conditional_swaprP   _   s    1u!1a4Kr   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZefdZd ZeefdZd Zd Zd Zd Zd Zd Zd Zd ZefdZd Zd Zd Z d Z!d Z"y) 
TestUnpackc                 R    t        |      }| j                   |        |              y r   )r   assertPreciseEqualselfpyfunccfuncs      r   check_nullary_npmzTestUnpack.check_nullary_npmh   s    V2r   c                 `     t        d      |      }| j                   |        |              y )NTr   )r   rT   rU   s      r   check_nullary_objmodez TestUnpack.check_nullary_objmodel   s'    "T"6*2r   c                 x    t         } t        d      |      }g d}| j                   ||       ||             y )NTr[   r-   )r   r   assertEqual)rV   rW   rX   r   s       r   test_unpack_listzTestUnpack.test_unpack_listp   s5    "T"6*q6!9-r   c                 "   t         } t        t        j                  t        j                  dd      fd      |      }t        j                  d      j                  t
        j                        }| j                   ||       ||             y )Nr    CdtypendimlayoutTr[   r-   r   )	r   r   r   Arrayint32rE   rF   astyperT   rV   rW   rX   r   s       r   test_unpack_shapezTestUnpack.test_unpack_shapev   sk    #U[[u{{3GI!##)+HH9%,,RXX6a&)4r   c                    t         } t        t        j                  t        j                  dd      f      |      }t        j                  d      j                  t
        j                        }| j                   ||       ||             y )Nr    ra   rb   r-   r   )	r   r   r   rf   rg   rE   rF   rh   rT   ri   s       r   test_unpack_shape_npmz TestUnpack.test_unpack_shape_npm}   sh    ekk!CHJ HH9%,,RXX6a&)4r   c                 .    | j                  t               y r   )r\   r$   rV   s    r   test_unpack_rangezTestUnpack.test_unpack_range       ""<0r   c                 .    | j                  t               y r   )rY   r$   rn   s    r   test_unpack_range_npmz TestUnpack.test_unpack_range_npm       |,r   c                 .    | j                  t               y r   )r\   r/   rn   s    r   test_unpack_tuplezTestUnpack.test_unpack_tuple   rp   r   c                 .    | j                  t               y r   )rY   r/   rn   s    r   test_unpack_tuple_npmz TestUnpack.test_unpack_tuple_npm   rs   r   c                 .    | j                  t               y r   )r\   r=   rn   s    r   test_unpack_heterogeneous_tuplez*TestUnpack.test_unpack_heterogeneous_tuple   s    ""#=>r   c                 .    | j                  t               y r   )rY   r=   rn   s    r   #test_unpack_heterogeneous_tuple_npmz.TestUnpack.test_unpack_heterogeneous_tuple_npm   s    9:r   c                 .    | j                  t               y r   )r\   r?   rn   s    r   &test_unpack_nested_heterogeneous_tuplez1TestUnpack.test_unpack_nested_heterogeneous_tuple   s    ""#DEr   c                 .    | j                  t               y r   )rY   r?   rn   s    r   *test_unpack_nested_heterogeneous_tuple_npmz5TestUnpack.test_unpack_nested_heterogeneous_tuple_npm   s    @Ar   c                     t         } t        t        j                  t        j                  ffi ||      }d}| j	                   ||  ||        y )N)r*      )rN   r   r   rg   rT   )rV   flagsrW   rX   argss        r   test_chained_unpack_assignz%TestUnpack.test_chained_unpack_assign   sG    '8U[[%++.8%8@tfdm<r   c                 0    | j                  t               y )N)r   )r   r
   rn   s    r   test_chained_unpack_assign_npmz)TestUnpack.test_chained_unpack_assign_npm   s    ''n'=r   c                     | j                  |      5   t        di ||      } |        d d d        y # 1 sw Y   y xY w)N)r   )assertRaisesr   )rV   rW   r   excrX   s        r   check_unpack_errorzTestUnpack.check_unpack_error   s5    s#$C$e$V,EG $##s   4=c                 X    | j                  t               | j                  t               y r   )r   r2   r7   rn   s    r   test_unpack_tuple_too_smallz&TestUnpack.test_unpack_tuple_too_small         67 DEr   c                     | j                  t        t        t        j                         | j                  t
        t        t        j                         y r   )r   r2   r
   r   TypingErrorr7   rn   s    r   test_unpack_tuple_too_small_npmz*TestUnpack.test_unpack_tuple_too_small_npm   ;     6 & 2 2	4 D .0B0B	Dr   c                 X    | j                  t               | j                  t               y r   )r   r4   r;   rn   s    r   test_unpack_tuple_too_largez&TestUnpack.test_unpack_tuple_too_large   r   r   c                     | j                  t        t        t        j                         | j                  t
        t        t        j                         y r   )r   r4   r
   r   r   r;   rn   s    r   test_unpack_tuple_too_large_npmz*TestUnpack.test_unpack_tuple_too_large_npm   r   r   c                 .    | j                  t               y r   )r   r(   rn   s    r   test_unpack_range_too_smallz&TestUnpack.test_unpack_range_too_small        67r   c                 8    | j                  t        t               y r   )r   r(   r
   rn   s    r   test_unpack_range_too_small_npmz*TestUnpack.test_unpack_range_too_small_npm        6Gr   c                 .    | j                  t               y r   )r   r+   rn   s    r   test_unpack_range_too_largez&TestUnpack.test_unpack_range_too_large   r   r   c                 8    | j                  t        t               y r   )r   r+   r
   rn   s    r   test_unpack_range_too_large_npmz*TestUnpack.test_unpack_range_too_large_npm   r   r   c                      t        t        j                  t        j                  ffi |t              }| j	                   |dd      d       | j	                   |dd      d       y )Nr*   r   )r   r*   r   )r   r   )r   r   rg   rP   rT   )rV   r   rX   s      r   check_conditional_swapz!TestUnpack.check_conditional_swap   sR    8U[[%++.8%89IJaV4aV4r   c                 $    | j                          y r   )r   rn   s    r   test_conditional_swapz TestUnpack.test_conditional_swap   s    ##%r   c                 .    | j                  t               y r   )r   r
   rn   s    r   test_conditional_swap_npmz$TestUnpack.test_conditional_swap_npm   s    ##N3r   c                     t        d t        d      D              }t        |      }t        } t	        |f      |      }| j                   ||       ||             y )Nc              3   L   K   | ]  }t        j                  |d z           yw)r.   NrD   ).0is     r   	<genexpr>z9TestUnpack.test_unpack_tuple_of_arrays.<locals>.<genexpr>   s     6XBHHQUOXs   "$r'   )tupler"   r   rB   r   rT   )rV   rG   tuptyrW   rX   s        r   test_unpack_tuple_of_arraysz&TestUnpack.test_unpack_tuple_of_arrays   sN    6U1X66s!eXv&c
F3K8r   c                 j    t         } t        d      |      }| j                   |        |              y )Nr   )rJ   r   rT   rU   s      r   test_unpack_nrtzTestUnpack.test_unpack_nrt   s+    R	&!2r   c                    t         }| j                  t        j                        5 } t	        t
        j                  f      |       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)Nzfailed to unpack int32)
rB   r   r   r   r   r   rg   assertInstr	exception)rV   rW   raisess      r   test_invalid_unpackzTestUnpack.test_invalid_unpack   sZ    !v112f D%++ ( 3.F4D4D0EF 32s   !A55A>N)#__name__
__module____qualname__rY   r\   r_   rj   rl   ro   rr   ru   rw   ry   r{   r}   r   r   r   r   
ValueErrorr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rR   rR   f   s    33.551-1-?;FB 0A => 0A)FDFD8H8H ,= 5
&493
Gr   rR   __main__)$numpyrE   unittestnumbar   r   
numba.corer   r   r   numba.tests.supportr   r	   r
   nullary_no_pyobj_flagsr   nullary_force_pyobj_flagsr   r   r$   r(   r+   r/   r2   r4   r7   r;   r=   r?   rB   rJ   rN   rP   rR   r   mainr   r   r   <module>r      s       $  9 H N& d#












@G( @GF zHMMO r   