
    %YHh4                        d dl Z d dlZd dlZd dlmZ d dlmZ  ed       G d de j                               Z	 ed       G d de j                               Z
 ed       G d	 d
e j                               Z ed       G d de j                               Z ed       G d de j                               Zedk(  r e j                          yy)    N)Array)skip_on_cudasimz/Tests internals of the CUDA driver device 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        `/var/www/html/planif/env/lib/python3.12/site-packages/numba/cuda/tests/nocuda/test_dummyarray.pyassertSameContigzTestSlicing.assertSameContig   sg    . 	8Dyy%++d"3388q=UZZ1_ II"yy%++7 8	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_1d2   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/   r0   r   r   r   r&   r'   r(   r)   r1   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 Nr4   r   )r   r   r   )r   r   r   r   r    r!   r"   r#   r$   r   r/   r0   r6   s           r   test_slice1_2dzTestSlicing.test_slice1_2dS   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 r9   r.   )r   r   r   r&   stuvr(   r)   r'   r1   s               r   test_slice2_2dzTestSlicing.test_slice2_2df   s\    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_1d{   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 )Nr4   r   rB   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   r5      r   rB   r.   )	r   r   r   r&   rE   rF   cr(   r)   s	            r   test_strided_3dzTestSlicing.test_strided_3d   s    #ooaemm#kk224 ((R4 	:GAq!3Q3!SqS=)Fcc3Q3!m$C!!#v.SYY5S[[&..9	:r   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,   r2   r7   r:   r@   rC   rG   rK   rQ    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 )Nr4   r   r5   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 )Nr4   r      rY   r[   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rM   r   r5   r   r5   rM   r   rY   r[   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 )Nra   r      r5   rY   r[   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 )Nra   r   <   rY   r[   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 )Nr4   r   r   r   rY   r[   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 )Nr4   r   r   rY   r[   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 )Nra   r   r5   r   r   rY   r[   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 )Nra   r   rM   r   rY   r[   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 )Nra   r   r   rY   r[   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)Nra   r   r   rM   z&can only specify one unknown dimensionr   r   r   r   r    r!   r"   r#   assertRaises
ValueErrorrZ   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"	#>&**+	-	# 	#s   +B--B6c                 t   t        j                  d      }t        j                  d|j                  |j
                  |j                  j                        }| j                  t              5 }|j                  dd       d d d        d}| j                  |t        j                               y # 1 sw Y   1xY w)Nra   r   r      z.cannot infer valid shape for unknown dimensionrt   )r   r   r   rz   expected_messages        r    test_reshape_infer_invalid_shapez,TestReshape.test_reshape_infer_invalid_shape  s    #ooaemm#kk224 z* 	fKKA	 L&F,<,<(=>		 	s   +B..B7N)rR   rS   rT   r\   r_   rb   re   rh   rj   rl   rn   rp   rr   r{   r   rU   r   r   rW   rW      s>    6666666666-	?r   rW   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   rM   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	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   rM   )r   r   r   r   r    r!   r"   r#   ru   rv   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)rR   rS   rT   r   r   rU   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_1d8  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 )Nr4   r   r   r   s        r   test_extent_2dzTestExtent.test_extent_2d?  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_1dF  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 )Nr4   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_2dM  s     ooaemm#kk224S//12cjj)T#cc("A"A"CDEqIr   N)rR   rS   rT   r   r   r   r   rU   r   r   r   r   6  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 )Nr5   r   )r   r   r   r   r    r!   r"   r#   )r   Nr   r   r'   vals         r   test_for_loopzTestIterate.test_for_loopY  sX    ooaemm#kk224  	CA	r   N)rR   rS   rT   r   rU   r   r   r   r   W  s    
r   r   __main__)unittestr/   numpyr   numba.cuda.cudadrv.dummyarrayr   numba.cuda.testingr   TestCaser   rW   r   r   r   rR   mainrU   r   r   <module>r      s      / . BC[M(## [M D[M| BCn?(## n? Dn?b BC%(## % D%8 BCJ"" J DJ@ BC(##  D zHMMO r   