U
    -e                     @   sp   d dl mZmZmZ d dlZd dlZd dlmZ d dl	m
Z
 dd Zdd ZG d	d
 d
e
Zedkrle  dS )    )print_functionabsolute_importdivisionN)guvectorize)TestCasec                 C   s(   t d| jd dD ]}|d | |< qd S )Nr      rangeshape)x_ty_1t r   i/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/numba/tests/npyufunc/test_update_inplace.pypy_replace_2nd   s    r   c                 C   sF   t d| jd D ]0}|d | |< d|d  ||< d|d  ||< qd S )Nr   r      r   )x0_tx1_tZx2_tr   r   r   r   r   py_update_3   s    r   c                   @   s>   e Zd ZdddZdd Zdd Zd	d
 Zdd Zdd ZdS )TestUpdateInplaceTr   c                    s   dd|ffD ]\ } fddt |jd D }dd |D }|||f  ||t|gf  tt||D ]B\}\}	}
|rtjj|	|
d| d qp| j|	|
k	 d| d	 qpqd S )
N)Zf8TZf4c                    s   g | ]}t d  qS )
   )npZzeros).0_Zdtyper   r   
<listcomp>   s     z:TestUpdateInplace._run_test_for_gufunc.<locals>.<listcomp>   c                 S   s   g | ]}|  qS r   )copy)r   r   r   r   r   r      s     zinput %s)err_msg)msg)
r	   Zninr   array	enumerateziptestingZassert_equalZassertFalseall)selfgufuncZpy_funcexpect_f4_to_passzZexpect_to_passinputsZ	ex_inputsir   Zex_x_tr   r   r   _run_test_for_gufunc   s    z&TestUpdateInplace._run_test_for_gufuncc                 C   sl   t dgdddt}| j|tdd t dgddddt}| |t t dgddd	dt}| |t d S )
Nvoid(f8[:], f8[:])(t),()TnopythonFr'   r   r/   writable_args)r   r   r   r+   r%   r&   r   r   r   test_update_inplace(   s*     
z%TestUpdateInplace.test_update_inplacec                 C   s@   t dgdddddt}t dgdddddt}| |t d S )Nr,   r-   Tr1   )r/   r3   cacher4   r5   r   r   r   test_update_inplace_with_cache9   s      z0TestUpdateInplace.test_update_inplace_with_cachec                 C   s(   t dgdddddt}| |t d S )Nr,   r-   Tr1   parallelr/   r3   targetr4   r5   r   r   r   test_update_inplace_parallelD   s     z.TestUpdateInplace.test_update_inplace_parallelc                 C   sl   t dgdddt}| j|tdd t dgddddt}| |t t dgddd	dt}| |t d S )
Nz void(f8[:], f8[:], f8[:], f8[:])z(t),(t),(t),()Tr.   Fr0   )r   r   r   r2   )r   r   r   )r   r   r+   r5   r   r   r   test_update_inplace_3K   s.      z'TestUpdateInplace.test_update_inplace_3c              	   C   s   |  t tdgddddt W 5 Q R X |  t tdgddddt W 5 Q R X |  t tdgddddt W 5 Q R X |  t tdgddddt W 5 Q R X |  t tdgddd	d
dt W 5 Q R X d S )Nr,   r-   T)r   r   r      r2   )r>   ))Zz_tr1   cudar:   )assertRaises
ValueErrorr   r   RuntimeError	TypeError)r%   r   r   r   test_exceptions^   sF    
    z!TestUpdateInplace.test_exceptionsN)Tr   )	__name__
__module____qualname__r+   r6   r8   r<   r=   rE   r   r   r   r   r      s     
r   __main__)
__future__r   r   r   Zunittestnumpyr   Znumbar   Znumba.tests.supportr   r   r   r   rF   mainr   r   r   r   <module>   s   b