
    J/Ph                        d dl Zd dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlZd Zd Zd	 Zd
 Z G d dee          Z G d dee          Z G d de          Z G d de          Zedk    r ej                     dS dS )    N)SerialMixin)typeofcudanjit)float64)TestCaseMemoryLeakMixin)configc                     | d         S N
    as    \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/tests/test_boundscheck.pybasic_array_accessr      s    R5L    c                     | dd df         S r   r   r   s    r   slice_array_accessr      s    RSS"W:r   c                 >    t          j        g d          }| |         S )N         nparrayxr   s     r   fancy_array_accessr       s    
AQ4Kr   c                 <    t          j        g d          }d| |<   | S )Nr   r   r   r   s     r   fancy_array_modifyr"      s#    
AAaDHr   c                       e Zd Z ej        ddi          d             Z ej        ddi          d             Z ej        ddi          d             ZdS )TestBoundsCheckNoErrorNUMBA_BOUNDSCHECK envvarsc                 ^   |                      t          j                   t          j        d          }|                     t                    5  t          |           d d d            n# 1 swxY w Y   t          |          } t          |f          t                    } ||           d S )N   
assertIsNoner
   BOUNDSCHECKr   arangeassertRaises
IndexErrorr   r   r   )selfr   atnoboundschecks       r   test_basic_array_boundscheckz3TestBoundsCheckNoError.test_basic_array_boundscheck!   s    &,---IaLLz** 	" 	" q!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
 AYY#bU$677as   A**A.1A.c                 N   |                      t          j                   t          j        d          }t          j        d          }|                     t                    5  t          |           d d d            n# 1 swxY w Y   t          |           t          |          }t          d d          } t           ||                    t                    } t           ||          d          t                    } ||            ||            ||           d S N)r*   r*   )r*      Tboundscheckr,   r
   r-   r   onesr/   r0   r   r   r   r   r1   r   br2   rtr3   r9   s          r   test_slice_array_boundscheckz3TestBoundsCheckNoError.test_slice_array_boundscheck2   sL   &,---GFOOGGz** 	" 	" q!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
 	1AYYQQQZ$RRVV%7884d22b66t4445GHHaa 	A   "A>>BBc                 N   |                      t          j                   t          j        d          }t          j        d          }|                     t                    5  t          |           d d d            n# 1 swxY w Y   t          |           t          |          }|j	        d d          } t           ||                    t                    } t           ||          d          t                    } ||            ||            ||           d S Nr      Tr8   r,   r
   r-   r   r.   r/   r0   r    r   dtyper   r<   s          r   test_fancy_indexing_boundscheckz6TestBoundsCheckNoError.test_fancy_indexing_boundscheckK   sN   &,---IaLLIaLL z** 	" 	" q!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	1AYYXaaa[$RRVV%7884d22b66t4445GHHaa 	Ar@   N)__name__
__module____qualname__r   run_test_in_subprocessr4   r?   rF   r   r   r   r$   r$      s        $X$.A2-FGGG  HG  %X$.A2-FGGG  HG0 %X$.A2-FGGG  HG  r   r$   c                       e Zd Z ej         ej                     d           ej        ddi          d                         Z	dS )TestNoCudaBoundsCheckzNO CUDAr%   1r'   c                    |                      t          j                   |                     t                    5  t          j        d          d             }d d d            n# 1 swxY w Y   t          j        d          d             }t
          j        d             }t          j        d          }t          j	        d          }t          j
        s |d         ||           d S d S )	NTr8   c                      d S Nr   r   r   r   funcz<TestNoCudaBoundsCheck.test_no_cuda_boundscheck.<locals>.funcl   s    r   Fc                      d S rP   r   r   r   r   func3z=TestNoCudaBoundsCheck.test_no_cuda_boundscheck.<locals>.func3r   s    Dr   c                     | d         |d<   d S Nr   r   r   s     r   func2z=TestNoCudaBoundsCheck.test_no_cuda_boundscheck.<locals>.func2v   s    Q4AaDDDr   )r   )r   r   )
assertTruer
   r-   r/   NotImplementedErrorr   jitr   r;   zerosENABLE_CUDASIM)r1   rQ   rS   rV   r   r   s         r   test_no_cuda_boundscheckz.TestNoCudaBoundsCheck.test_no_cuda_boundscheckg   s?    	*+++233 	 	X$'''  ('	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 
e	$	$	$	 	 
%	$	 
	 	 
	 GDMMHTNN $ 	E$K1	 	s   A%%A),A)N)
rG   rH   rI   unittestskipIfr   is_availabler   rJ   r\   r   r   r   rL   rL   f   sm        X_**,,,i88$X$.A3-GHHH  IH 98  r   rL   c                       e Zd Z ej        ddi          d             Z ej        ddi          d             Z ej        ddi          d             Z ej        ddi          d             ZdS )	TestBoundsCheckErrorr%   r&   r'   c                    |                      t          j                   t          j        d          }|                     t                    5  t          |           d d d            n# 1 swxY w Y   t          |          } t          |fd          t                    }|                     t                    5   ||           d d d            d S # 1 swxY w Y   d S )Nr*   Tr8   r+   )r1   r   r2   r9   s       r   r4   z1TestBoundsCheckError.test_basic_array_boundscheck   sP   &,---IaLLz** 	" 	" q!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
 AYY3dB5d3334FGGz** 	 	KNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s$   A**A.1A.>CCCc                 <   |                      t          j                   t          j        d          }t          j        d          }|                     t                    5  t          |           d d d            n# 1 swxY w Y   t          |           t          |          }t          d d          } t           ||          d          t                    }|                     t                    5   ||           d d d            d S # 1 swxY w Y   d S r6   r:   r1   r   r=   r2   r>   r9   s         r   r?   z1TestBoundsCheckError.test_slice_array_boundscheck   s   &,---GFOOGGz** 	" 	" q!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
 	1AYYQQQZ4d22b66t4445GHHz** 	 	KNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	$   "A>>BB8DDDc                 <   |                      t          j                   t          j        d          }t          j        d          }|                     t                    5  t          |           d d d            n# 1 swxY w Y   t          |           t          |          }|j	        d d          } t           ||          d          t                    }|                     t                    5   ||           d d d            d S # 1 swxY w Y   d S rB   rD   rd   s         r   rF   z4TestBoundsCheckError.test_fancy_indexing_boundscheck      &,---IaLLIaLL z** 	" 	" q!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	1AYYXaaa[4d22b66t4445GHHz** 	 	KNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	re   c                 <   |                      t          j                   t          j        d          }t          j        d          }|                     t                    5  t          |           d d d            n# 1 swxY w Y   t          |           t          |          }|j	        d d          } t           ||          d          t                    }|                     t                    5   ||           d d d            d S # 1 swxY w Y   d S rB   )r,   r
   r-   r   r.   r/   r0   r"   r   rE   r   rd   s         r   1test_fancy_indexing_with_modification_boundscheckzFTestBoundsCheckError.test_fancy_indexing_with_modification_boundscheck   rg   re   N)	rG   rH   rI   r   rJ   r4   r?   rF   ri   r   r   r   ra   ra      s        $X$.A2-FGGG  HG  %X$.A2-FGGG  HG& %X$.A2-FGGG  HG( %X$.A2-FGGG  HG  r   ra   c                       e Zd Zd Z ej        ddi          d             Z ej        ddi          d             Z ej        ddi          d	             Zd
S )TestBoundsEnvironmentVariablec                     t           d             }t          d          d             }t          d          d             }|| _        || _        || _        d S )Nc                     | d         S rU   r   r   s    r   defaultz4TestBoundsEnvironmentVariable.setUp.<locals>.default       Q4Kr   Fr8   c                     | d         S rU   r   rn   s    r   offz0TestBoundsEnvironmentVariable.setUp.<locals>.off   rp   r   Tc                     | d         S rU   r   rn   s    r   onz/TestBoundsEnvironmentVariable.setUp.<locals>.on   rp   r   )r   ro   rr   rt   )r1   ro   rr   rt   s       r   setUpz#TestBoundsEnvironmentVariable.setUp   s    		 	 
	 
%	 	 	 	 	 
!	 	 
$				 	 
 		 r   r%   r&   r'   c                 R   |                      t          j                   t          j        dg          }|                     |           |                     |           |                     t                    5  | 	                    |           d d d            d S # 1 swxY w Y   d S rU   )
r,   r
   r-   r   r   ro   rr   r/   r0   rt   r1   r   s     r   test_boundscheck_unsetz4TestBoundsEnvironmentVariable.test_boundscheck_unset   s    &,---HaSMM 	Qz** 	 	GGAJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   9BB #B rM   c                 R   |                      t          j                   t          j        dg          }|                     t                    5  |                     |           |                     |           | 	                    |           d d d            d S # 1 swxY w Y   d S rU   )
rW   r
   r-   r   r   r/   r0   ro   rr   rt   rw   s     r   test_boundscheck_enabledz6TestBoundsEnvironmentVariable.test_boundscheck_enabled   s    *+++HaSMMz** 	 	LLOOOHHQKKKGGAJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A BB #B 0c                     |                      t          j                   t          j        dg          }|                     |           |                     |           |                     |           d S rU   )assertFalser
   r-   r   r   ro   rr   rt   rw   s     r   test_boundscheck_disabledz7TestBoundsEnvironmentVariable.test_boundscheck_disabled   s[    +,,,HaSMM 	Q




r   N)	rG   rH   rI   ru   r   rJ   rx   rz   r~   r   r   r   rk   rk      s          " %X$.A2-FGGG
 
 HG
 %X$.A3-GHHH  IH %X$.A3-GHHH  IH  r   rk   __main__)numpyr   numba.cuda.testingr   numbar   r   r   numba.core.typesr   numba.tests.supportr   r	   
numba.corer
   r]   r   r   r    r"   r$   rL   ra   rk   rG   mainr   r   r   <module>r      s       * * * * * * $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 9 9 9 9 9 9 9 9           
  
  D D D D D_h D D DN    K   <N N N N N8 N N Nb3 3 3 3 3H 3 3 3l zHMOOOOO r   