
    xKg#3                     (   d dl Z d dlZd dlZd dlmZ  G d de j                        Z G d de j                        Z G d de j                        Z	 G d	 d
e j                        Z
 G d de j                        Zedk(  r e j                          yy)    N)Arrayc                   N    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y)TestSlicingc                     d}|D ]l  }|j                   |   |j                   |   k7  s#|j                  dk(  r|j                  dk(  rB| j                  d|j                   d|j                          n y )N)C_CONTIGUOUSF_CONTIGUOUSr   zcontiguous flag mismatch:
got=z
expect=)flagssizefail)selfarrnparrattrsattrs        _/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_dummyarray.pyassertSameContigzTestSlicing.assertSameContig	   sb    .Dyy%++d"3388q=UZZ1_ II"yy%++7 8     c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }| j                  ||       d}|D ]j  }||d  }||d  }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                         l y N   r   )r         
npemptyr   	from_descshapestridesdtypeitemsizer   assertEqualr   r   r   xxxexpectgots          r   test_slice0_1dzTestSlicing.test_slice0_1d   s    ooaemm#kk224c5)A12YFab'C!!#v.SYY5S[[&..9 r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}|D ]j  }|d | }|d | }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                         l y r   r   r$   s          r   test_slice1_1dzTestSlicing.test_slice1_1d$   s    ooaemm#kk224A2AYFbq'C!!#v.SYY5S[[&..9 r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}t        j                  ||      D ]m  \  }}||| }||| }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                         o y r   r   r   r   r   r   r    r!   r"   	itertoolsproductr   r#   )r   r   r   r%   r&   yr'   r(   s           r   test_slice2_1dzTestSlicing.test_slice2_1d0   s    ooaemm#kk224%%b"-DAq1QZFa(C!!#v.SYY5S[[&..9 .r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}|D ]j  }||d  }||d  }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                         l t        j                  ||      D ]y  \  }}||d |d f   }||d |d f   }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                         { y )N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   s           r   test_slice0_2dzTestSlicing.test_slice0_2d>   s    ooaemm#kk224A12YFab'C!!#v.SYY5S[[&..9  %%b"-DAq12qr6]Fab!"f+C!!#v.SYY5S[[&..9 .r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}|D ]j  }|d | }|d | }| j                  |j                  |j                         | j                  |j
                  |j
                         | j                  ||       l t        j                  ||      D ]y  \  }}|d |d |f   }|d |d |f   }| j                  |j                  |j                         | j                  |j
                  |j
                         | j                  ||       { y Nr3   r   )r   r   r   )r   r   r   r   r   r    r!   r"   r#   r   r.   r/   r5   s           r   test_slice1_2dzTestSlicing.test_slice1_2dQ   s%    ooaemm#kk224A2AYFbq'CSYY5S[[&..9!!#v.  %%b"-DAq2A2rr6]Fbqb"1"f+CSYY5S[[&..9!!#v. .r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}t        j                  ||||      D ]{  \  }}}}|||||f   }|||||f   }	| j                  |	|       | j                  |	j                  |j                         | j                  |	j
                  |j
                         } t        j                  ||      D ]y  \  }
}|f   }|||||f   }	| j                  |	|       | j                  |	j                  |j                         | j                  |	j
                  |j
                         { y r8   r-   )r   r   r   r%   stuvr'   r(   r&   r0   s               r   test_slice2_2dzTestSlicing.test_slice2_2dd   sR    ooaemm#kk224#++BB;JAq!Q1Q3!8_Fac1Q3h-C!!#v.SYY5S[[&..9 < %%b"-DAq1Q3!8_Fac1Q3h-C!!#v.SYY5S[[&..9 .r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}|D ]p  }|d d |   }|d d |   }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                         r y )Nr   r   r   r   r   r   r   r$   s          r   test_strided_1dzTestSlicing.test_strided_1dy   s    ooaemm#kk224A3Q3ZFcc(C!!#v.SYY5S[[&..9 r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}t        j                  ||      D ]}  \  }}|d d |d d |f   }|d d |d d |f   }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                          y )Nr3   r   rA   r-   )r   r   r   r%   abr'   r(   s           r   test_strided_2dzTestSlicing.test_strided_2d   s     ooaemm#kk224%%b"-DAq3Q3!8_Fcc3Q3h-C!!#v.SYY5S[[&..9 .r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }d}t        j                  |||      D ]  \  }}}|d d |d d |d d |f   }|d d |d d |d d |f   }| j                  ||       | j                  |j                  |j                         | j                  |j
                  |j
                          y )N)r   r4      r   rA   r-   )	r   r   r   r%   rD   rE   cr'   r(   s	            r   test_strided_3dzTestSlicing.test_strided_3d   s    #ooaemm#kk224 ((R4GAq!3Q3!SqS=)Fcc3Q3!m$C!!#v.SYY5S[[&..9 5r   c                 x   t        j                  d      }t        j                  |d      }t        j                  d|j
                  |j                  |j                        }| j                  |j                  d   |j                  d          | j                  |j                  d   |j                  d          y )N)r   r      )r   r   r   )axesr   r   r   )
r   r   	transposer   r   r   r    r"   r#   r	   )r   zr   s      r   test_issue_2766zTestSlicing.test_issue_2766   s    HHYLL+ooa!))QZZ@0#))N2KL0#))N2KLr   N)__name__
__module____qualname__r   r)   r+   r1   r6   r9   r?   rB   rF   rJ   rP    r   r   r   r      s:    
8:
:
::&/&:*
:
:
:Mr   r   c                   T    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y)TestReshapec                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  dd      }|j                  dd      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr3   r   r4   r   
r   r   r   r   r   r    r!   r"   reshaper#   r   r   r   r'   r(   s        r   test_reshape_2d2dzTestReshape.test_reshape_2d2d   s     ooaemm#kk224q!$kk!Q"FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  d      }|j                  d      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr3   r      rX   rZ   s        r   test_reshape_2d1dzTestReshape.test_reshape_2d1d   s     ooaemm#kk224u%kk% #FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  ddd      }|j                  ddd      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )NrL   r   r4   r   r4   rL   r   rX   rZ   s        r   test_reshape_3d3dzTestReshape.test_reshape_3d3d   s    #ooaemm#kk224q!Q'kk!Q"1%FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  dd      }|j                  dd      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr`   r      r4   rX   rZ   s        r   test_reshape_3d2dzTestReshape.test_reshape_3d2d   s    #ooaemm#kk224ua(kk%#A&FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  d      }|j                  d      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr`   r   <   rX   rZ   s        r   test_reshape_3d1dzTestReshape.test_reshape_3d1d   s    #ooaemm#kk224y)kk)$Q'FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  dd      }|j                  dd      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr3   r   r   r   rX   rZ   s        r   test_reshape_infer2d2dz"TestReshape.test_reshape_infer2d2d   s     ooaemm#kk224r1%kk"a #FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  d      }|j                  d      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr3   r   r   rX   rZ   s        r   test_reshape_infer2d1dz"TestReshape.test_reshape_infer2d1d   s     ooaemm#kk224r"kk"oa FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  ddd      }|j                  ddd      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr`   r   r4   r   r   rX   rZ   s        r   test_reshape_infer3d3dz"TestReshape.test_reshape_infer3d3d   s    #ooaemm#kk224q"a(kk!R#A&FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  dd      }|j                  dd      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr`   r   rL   r   rX   rZ   s        r   test_reshape_infer3d2dz"TestReshape.test_reshape_infer3d2d   s    #ooaemm#kk224q"%kk!R #FLL1fnn5r   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  d      }|j                  d      d   }| j                  |j                  |j                         | j                  |j
                  |j
                         y )Nr`   r   r   rX   rZ   s        r   test_reshape_infer3d1dz"TestReshape.test_reshape_infer3d1d   s    #ooaemm#kk224r"kk"oa FLL1fnn5r   c                 r   t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }| j                  t              5 }|j                  ddd       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)Nr`   r   r   rL   z&can only specify one unknown dimensionr   r   r   r   r   r    r!   r"   assertRaises
ValueErrorrY   assertInstr	exceptionr   r   r   raisess       r   test_reshape_infer_two_unknownsz+TestReshape.test_reshape_infer_two_unknowns   s    #ooaemm#kk224 z*fKKB" +>FDTDT@UV +*s   +B--B6c                 p   t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }| j                  t              5 }|j                  dd       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)Nr`   r   r      z.cannot infer valid shape for unknown dimensionrs   ry   s       r    test_reshape_infer_invalid_shapez,TestReshape.test_reshape_infer_invalid_shape	  s    #ooaemm#kk224 z*fKKA +FFL\L\H]^ +*s   +B,,B5N)rQ   rR   rS   r[   r^   ra   rd   rg   ri   rk   rm   ro   rq   r{   r~   rT   r   r   rV   rV      s@    6666666666W_r   rV   c                       e Zd Zd Zd Zy)TestSqueezec                     t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        } fd} |||        ||j                         d   |j                                dD ].  } ||j                  |      d   |j                  |             0 y )Nr   r   r   r   r   rL   r   c                     j                  | j                  |j                         j                  | j                  |j                         y )N)r#   r   r    )arr1arr2r   s     r   _assert_equal_shape_stridesz=TestSqueeze.test_squeeze.<locals>._assert_equal_shape_strides  s3    TZZ4T\\4<<8r   )r   r   r   )r   r   )r   r   )r   r   )r   r   r   axis)	r   r   r   r   r   r    r!   r"   squeeze)r   r   r   r   r   s   `    r   test_squeezezTestSqueeze.test_squeeze  s    +,oou{{EMM5;;+?+?
	9 	$C/#CKKM!$4emmoF@D'&q)5==d=+C Ar   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }| j                  t              5  |j                  d       d d d        | j                  t              5  |j                  d       d d d        y # 1 sw Y   :xY w# 1 sw Y   y xY w)Nr   r   r   r   )r   rL   )r   r   r   r   r   r    r!   r"   rt   ru   r   )r   r   r   s      r   test_squeeze_invalid_axisz%TestSqueeze.test_squeeze_invalid_axis#  s    +,oou{{EMM5;;+?+?
 z*KKQK +z*KKVK$ +* +***s   +B7C7C CN)rQ   rR   rS   r   r   rT   r   r   r   r     s    %r   r   c                   $    e Zd Zd Zd Zd Zd Zy)
TestExtentc                 8   t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  \  }}| j                  ||z
  |j                  |j                  j                  z         y Nr   r   r   r   r   r   r   r    r!   r"   extentr#   r
   r   r   r   r;   es        r   test_extent_1dzTestExtent.test_extent_1d/  sl    ooaemm#kk224zz1Q

U[[-A-A ABr   c                 8   t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }|j                  \  }}| j                  ||z
  |j                  |j                  j                  z         y )Nr3   r   r   r   s        r   test_extent_2dzTestExtent.test_extent_2d6  sm     ooaemm#kk224zz1Q

U[[-A-A ABr   c                    t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }t        |j                               \  }| j                  ||j                         y r   )r   r   r   r   r   r    r!   r"   listiter_contiguous_extentr#   r   r   r   r   exts       r   test_extent_iter_1dzTestExtent.test_extent_iter_1d=  sa    ooaemm#kk224S//12cjj)r   c           
         t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }t        |j                               \  }| j                  ||j                         | j                  t        t        |d d d   j                                     d       y )Nr3   r   r   )r   r   r   r   r   r    r!   r"   r   r   r#   r   lenr   s       r   test_extent_iter_2dzTestExtent.test_extent_iter_2dD  s     ooaemm#kk224S//12cjj)T#cc("A"A"CDEqIr   N)rQ   rR   rS   r   r   r   r   rT   r   r   r   r   .  s    CC*Jr   r   c                       e Zd Zd Zy)TestIteratec                     d}t        j                  |      }t        j                  d|j                  |j
                  |j                  j                        }d}|D ]  }|} y )Nr4   r   )r   r   r   r   r   r    r!   r"   )r   Nr   r   r&   vals         r   test_for_loopzTestIterate.test_for_loopO  sS    ooaemm#kk224 CA r   N)rQ   rR   rS   r   rT   r   r   r   r   N  s    
r   r   __main__)unittestr.   numpyr   numba.misc.dummyarrayr   TestCaser   rV   r   r   r   rQ   mainrT   r   r   <module>r      s       '[M(## [M|k_(## k_\%(## %6J"" J@(##  zHMMO r   