o
    ۾i>n                     @   s  d dl Z d dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZmZ dd Zdd	 ZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZedkre   dS dS )    N)voidfloat32float64int32int64jitguvectorize)TypingError)GUVectorize)tagTestCasec           	   
   C   sv   | j \}}|j \}}t|D ]*}t|D ]#}d|||f< t|D ]}|||f  | ||f |||f  7  < q qqdS )zdocstring for matmulcorer   N)shaperange)	ABCmnpijk r   T/home/ubuntu/.local/lib/python3.10/site-packages/numba/tests/npyufunc/test_gufunc.py
matmulcore   s   

*r   c                 C   s   | | | |d< d S Nr   r   axyoutr   r   r   axpy   s   r!   c                   @   @   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dS )
TestGUFunccpuc                 C   sv   d}t j|d d t jd|dd}t j|d d t jd|dd}|||}t ||}t jj||ddd d S 	Ni        dtype   h㈵>:0yE>rtolatolnparanger   reshapematmultestingassert_allclose)selfgufunc	matrix_ctr   r   r   Goldr   r   r   check_matmul_gufunc   s   ""
zTestGUFunc.check_matmul_gufuncc                 C   sf   t td| jd}|td d d d f td d d d f td d d d f f | }| | d S N(m,n),(n,p)->(m,p)target)r
   r   r?   addr   build_ufuncr;   r7   r8   r   r   r   test_gufunc(   s   @zTestGUFunc.test_gufuncc                 C   s\   t ttd d d d f td d d d f td d d d f gd| jdt}| | d S r<   )r   r   r   r?   r   r;   rB   r   r   r   test_guvectorize_decor0   s   >z!TestGUFunc.test_guvectorize_decorc                 C   sX   t td| jd}|d | }tjdtjd}||||}tj	||| |  d S )N(), (), () -> ()r>   z(intp, intp, intp, intp[:])
   r(   )
r
   r!   r?   r@   rA   r1   r2   intpr5   assert_equal)r7   r8   r   r    r   r   r   test_ufunc_like7   s   
zTestGUFunc.test_ufunc_likec                 C   sp   t dgddd }td}||dd}tj|dd}tj|| t|}|||dd tj|| d S )	Nzf8[:],f8[:](n)->(n)c                 S   0   d}t | jd D ]}|| | 7 }|||< q	d S r   r   r   r   resaccr   r   r   r   	my_cumsumF   
   
z'TestGUFunc.test_axis.<locals>.my_cumsum      r   axisr    rV   )r   r1   onescumsumr5   rH   
zeros_like)r7   rP   r   r   expectedout_kwr   r   r   	test_axisD   s   



zTestGUFunc.test_axisc                 C   sf   t td d  ttd d  fgddd }| d|j | d|j | d|j | d|j d S )N(n),()->(n)c                 S   s(   t | jd D ]
}| | | ||< qdS )docstring for gufuncr   NrL   r   r   rN   r   r   r   r   r8   X      z)TestGUFunc.test_docstring.<locals>.gufuncz numba.tests.npyufunc.test_gufuncr8   r_   )r   r   assertEqual
__module____name____qualname____doc__rB   r   r   r   test_docstringW   s    
zTestGUFunc.test_docstringN)
rd   rc   re   r?   r;   rC   rD   rI   r]   rg   r   r   r   r   r#      s    
r#   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )TestMultipleOutputsr$   c                 C   sj   t d| jddd }tjdtjdd }t|}t|}|||| tj|| tj|| d S )N(x)->(x),(x)r>   c                 S   s,   t |jD ]}| | ||< | | ||< qd S Nr   sizer   r   r   r   r   r   r   copyh   s   zKTestMultipleOutputs.test_multiple_outputs_same_type_passed_in.<locals>.copyrF   r(      r   r?   r1   r2   r   rZ   r5   r6   )r7   rn   r   r   r   r   r   r   )test_multiple_outputs_same_type_passed_ing   s   


z=TestMultipleOutputs.test_multiple_outputs_same_type_passed_inc                 C   sn   t d| jddd }tjdtjdd }t|}t|}|||| tj|| tj|d | d S )	Nri   r>   c                 S   0   t |jD ]}| | ||< | | d ||< qd S Nr&   rk   rm   r   r   r   copy_and_doublex      zRTestMultipleOutputs.test_multiple_outputs_distinct_values.<locals>.copy_and_doublerF   r(   ro   r&   rp   )r7   rt   r   r   r   r   r   r   %test_multiple_outputs_distinct_valuesv   s   


z9TestMultipleOutputs.test_multiple_outputs_distinct_valuesc                 C   sz   t d| jddd }tjdtjdd }t|}tj|tjd}|||| tj|| tj|td | d S )	Nri   r>   c                 S   rr   )N      ?rk   rm   r   r   r   copy_and_multiply   ru   zJTestMultipleOutputs.test_multiple_output_dtypes.<locals>.copy_and_multiplyrF   r(   ro   rw   )	r   r?   r1   r2   r   rZ   r   r5   r6   )r7   rx   r   r   r   r   r   r   test_multiple_output_dtypes   s   

z/TestMultipleOutputs.test_multiple_output_dtypesc                 C   s   t d| jddd }tjdtjd}d}| t}|| W d    n1 s)w   Y  | |t|j	 | t}|||||| W d    n1 sOw   Y  | |t|j	 d S )Nz(m),(m)->(m),(m)r>   c                 S      d S rj   r   )r   r   zwr   r   r   f   s   z@TestMultipleOutputs.test_incorrect_number_of_pos_args.<locals>.fr*   r(   z"Too few arguments for function 'f')
r   r?   r1   r2   r   assertRaises	TypeErrorassertInstr	exception)r7   r}   arrmsgter   r   r   !test_incorrect_number_of_pos_args   s   

z5TestMultipleOutputs.test_incorrect_number_of_pos_argsN)rd   rc   re   r?   rq   rv   ry   r   r   r   r   r   rh   d   s    rh   c                   @      e Zd ZdZdZdS )TestGUFuncParallelFparallelNrd   rc   re   _numba_parallel_test_r?   r   r   r   r   r          r   c                   @   r"   )TestDynamicGUFuncr$   c           
      C   s  dd }t td| jdd}d}tj|d d tjd	|dd}tj|d d
 tjd	|dd
}tj|d d
 tjd	|dd
}||||| tj|d d tjd	|dd}tj|d d
 tjd	|dd
}tj|d d
 tjd	|dd
}	|||||	 | t	|j
d d S )Nc                 S   s0   t ||}| ||| t jj||ddd d S )Nr+   r,   r-   )r1   r4   r5   r6   )r8   r   r   r   r:   r   r   r   r;      s   zBTestDynamicGUFunc.test_dynamic_matmul.<locals>.check_matmul_gufuncr=   Tr?   
is_dynamicrF   r&   r'   r(   r*   )r
   r   r?   r1   r2   r   r3   r   rb   lentypes)
r7   r;   r8   r9   Ai64Bi64Ci64r   r   r   r   r   r   test_dynamic_matmul   s   """"""z%TestDynamicGUFunc.test_dynamic_matmulc                 C   s8   dd }t td| jdd}tjdtjd}||| d S )Nc                 S   sj   t jd|jd}t jd|jd}| |||| | ||||d || | }t j|| t j|| d S )NrF   r(   r    )r1   zerosr)   r5   rH   )r8   r   r    r\   goldenr   r   r   check_ufunc_output   s   zETestDynamicGUFunc.test_dynamic_ufunc_like.<locals>.check_ufunc_outputrE   Tr   rF   r(   )r
   r!   r?   r1   r2   rG   )r7   r   r8   r   r   r   r   test_dynamic_ufunc_like   s   
z)TestDynamicGUFunc.test_dynamic_ufunc_likec                 C   s   t d| jdddd }| |j tjdtjddd	}tjdtjd}||| t	|j
d
 D ]}| || ||   q2d}| t| || W d   dS 1 sYw   Y  dS )w
        Note that scalar output is a 0-dimension array that acts as
        a pointer to the output location.
        (n)->()Tr?   nopythonc                 S   0   d}t | jd D ]}|| | 7 }q	||d< d S Ng        r   r   rL   inpr    tmpr   r   r   r   sum_row   s   z=TestDynamicGUFunc.test_dynamic_scalar_output.<locals>.sum_row0u  r(   '     r   z)Too few arguments for function 'sum_row'.N)r   r?   
assertTruer   r1   r2   r   r3   r   r   r   rb   sumassertRaisesRegexr   )r7   r   r   r    r   r   r   r   r   test_dynamic_scalar_output   s   



"z,TestDynamicGUFunc.test_dynamic_scalar_outputc                 C   sx   t ddd }td}tj|dd}t|}|||dd tj|| t|}|||dd tj|| d S )NrJ   c                 S   rK   r   rL   rM   r   r   r   rP      rQ   z.TestDynamicGUFunc.test_axis.<locals>.my_cumsumrR   r   rU   rW   )r   r1   rX   rY   rZ   r5   rH   )r7   rP   r   r[   r   r\   r   r   r   r]      s   



zTestDynamicGUFunc.test_axisc                 C   s  t ddd }g d}|D ]}t||}| |d|f  qtg d}tg d}||| | |tg d | |jd | t	}|
| W d    n1 sYw   Y  | t|jd	 | t	}|| W d    n1 s|w   Y  | t|jd	 | t	}||d
dg W d    n1 sw   Y  | t|jd	 | t}||| W d    n1 sw   Y  | t|jd d S )NrJ   c                 S   rK   r   rL   rM   r   r   r   r8     rQ   z8TestDynamicGUFunc.test_gufunc_attributes.<locals>.gufunc)	signature
accumulateatouterreducereduceatz!dynamic gufunc not exporting "%s"ro   r&   r   r'   r   r   r   r   ro   r      rF   z-Reduction not defined on ufunc with signaturer   r&   z?method outer is not allowed in ufunc with non-trivial signature)r   hasattrr   r1   arrayassertPreciseEqualrb   r   r~   RuntimeErrorr   r   r   r   r   r   r   )r7   r8   attrsattrcontainsr   rN   raisesr   r   r   test_gufunc_attributes  s6   


z(TestDynamicGUFunc.test_gufunc_attributesc                 C   s:  t ddd }| |j tg d}tg d}tg d}|||| | |tg d | |j | ||d | ||tg d	 | |	d
dgddgtddgddgg | |
|d
dgtddg tg d}tddg}||d
dg| | |tg d d S )Nz	(),()->()c                 S   s   | | |d< d S r   r   r   r   rN   r   r   r   r@   7     z6TestDynamicGUFunc.test_gufunc_attributes2.<locals>.addr   )r'   r   r&   ro   r   )r*   r*   r*   r*   rF   r   r   ro   r&   r      )r&   r'   r   r'   )r   assertIsNoner   r1   r   r   rb   r   r   r   r   r   )r7   r@   r   brN   r   r   r   r   r   test_gufunc_attributes26  s"   
."z)TestDynamicGUFunc.test_gufunc_attributes2N)
rd   rc   re   r?   r   r   r   r]   r   r   r   r   r   r   r      s    (r   c                   @   s<   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dS )TestGUVectorizeScalarz<
    Nothing keeps user from out-of-bound memory access
    r$   c                 C   sl   t dgd| jdddd }tjdtjdd	d
}||}t|jd D ]}| || || 	  q%dS )r   zvoid(int32[:], int32[:])r   Tr   c                 S   r   r   rL   r   r   r   r   r   ]  s   z9TestGUVectorizeScalar.test_scalar_output.<locals>.sum_rowr   r(   r   r   r   N)
r   r?   r1   r2   r   r3   r   r   rb   r   )r7   r   r   r    r   r   r   r   test_scalar_outputW  s   

z(TestGUVectorizeScalar.test_scalar_outputc                 C   sR   t dgd| jdddd }tjdtjdd	d
}||d}| |d | d S )Nzint32[:], int32[:], int32[:]r^   Tr   c                 S   s,   t | jd D ]}| | |d  ||< qd S r   rL   r   r   r    r   r   r   r   foor  s   z4TestGUVectorizeScalar.test_scalar_input.<locals>.foorT   r(   rF   r   r&   )r   r?   r1   r2   r   r3   r   )r7   r   r   r    r   r   r   test_scalar_inputp  s   

z'TestGUVectorizeScalar.test_scalar_inputc                 C   s   dd }t dgd| jd|}tdtj}||d}t|}||d| tj|| tdtj	dd}||d}t|}t
|jd	 D ]}||| d||  qMtj|| d S )
Nc                 S   s(   t | jD ]}|| | d  ||< qd S )Nro   rk   r   r   r   r   pyfunc  s   zATestGUVectorizeScalar.test_scalar_input_core_type.<locals>.pyfuncint32[:], int32, int32[:]r^   r>   rF   r&   rS   r   )r   r?   r1   r2   astyper   rZ   r5   rH   r3   r   r   )r7   r   	my_gufuncr   gotr[   axr   r   r   test_scalar_input_core_type  s$   



z1TestGUVectorizeScalar.test_scalar_input_core_typec                 C   Z   |  t}tdgd| jddd }W d    n1 sw   Y  | dt|j d S )Nr   z(n),(n)->(n)r>   c                 S   rz   rj   r   )r   r   cr   r   r   r        zGTestGUVectorizeScalar.test_scalar_input_core_type_error.<locals>.pyfuncz2scalar type int32 given for non scalar argument #2r~   r   r   r?   rb   r   r   r7   r   r   r   r   r   !test_scalar_input_core_type_error     z7TestGUVectorizeScalar.test_scalar_input_core_type_errorc                 C   r   )Nzint32[:], int32[:]z
(m,n)->(n)r>   c                 S   rz   rj   r   )r   r   r   r   r   r     r   z8TestGUVectorizeScalar.test_ndim_mismatch.<locals>.pyfuncz,type and shape signature mismatch for arg #1r   r   r   r   r   test_ndim_mismatch  r   z(TestGUVectorizeScalar.test_ndim_mismatchN)
rd   rc   re   rf   r?   r   r   r   r   r   r   r   r   r   r   Q  s    	r   c                   @   r   )TestGUVectorizeScalarParallelFr   Nr   r   r   r   r   r     r   r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestGUVectorizePicklingc                 C   s   t dgddd }t|}t|}| |j|j | |j|j | |j|j | |jj	|jj	 | 
|j |  | 
|j | |d|d td}| |||| dS )zNon-dynamic gufunc.
        zf8,f8[:]()->()c                 S      | d |d d < d S rs   r   r   r    r   r   r   double     zFTestGUVectorizePickling.test_pickle_gufunc_non_dyanmic.<locals>.double      ?rF   N)r   pickledumpsloadsrb   _frozenidentityr   gufunc_builder_sigsr   disable_compiler   r1   r2   )r7   r   serclonedr   r   r   r   test_pickle_gufunc_non_dyanmic  s    





z6TestGUVectorizePickling.test_pickle_gufunc_non_dyanmicc                 C   s   t ddddd }t|}t|}| |j|j | |j|j | |j|j | |jj	|jj	 | 
|j td}td}|d|d |d|d | || td}t|}t|}|||d |||d | || d	S )
z:Dynamic gufunc w/o prepopulating before pickling.
        r   ro   r   c                 S   r   rs   r   r   r   r   r   r     r   zLTestGUVectorizePickling.test_pickle_gufunc_dyanmic_null_init.<locals>.doubler   r   rF   N)r   r   r   r   rb   r   r   r   r   r   assertFalser1   r   r   r2   rZ   )r7   r   r   r   expectr   r   r   r   r   $test_pickle_gufunc_dyanmic_null_init  s,   









z<TestGUVectorizePickling.test_pickle_gufunc_dyanmic_null_initc                 C   sJ  t ddddd }td}td}|d|d td}t|}t|}|||d t|}t|}| |j	|j	 | |j
|j
 | |j|j | |jj|jj | |j	 |  | |j	 td}td}|d|d |d|d | || t|}t|}|||d |||d | || d	S )
zDynamic gufunc prepopulated before pickling.

        Once unpickled, we disable compilation to verify that the gufunc
        compilation state is carried over.
        r   ro   r   c                 S   r   rs   r   r   r   r   r   r     r   zNTestGUVectorizePickling.test_pickle_gufunc_dynamic_initialized.<locals>.doubler   r   rF   N)r   r1   r   r2   rZ   r   r   r   rb   r   r   r   r   r   r   r   r   r   )r7   r   r   r   r   r   r   r   r   r   &test_pickle_gufunc_dynamic_initialized  s<   













z>TestGUVectorizePickling.test_pickle_gufunc_dynamic_initializedN)rd   rc   re   r   r   r   r   r   r   r   r     s    "r   c                   @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zej	d
d Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"S )#TestGUVectorizeJitr$   c                    sb   t dd fdd}tjddddd	d
}td}t|}|||| | |||  d S )NTr   c                        | || d S rj   r   r   r8   r   r   jit_add)  r   z4TestGUVectorizeJit.check_add_gufunc.<locals>.jit_add(   i8r(   r'   r&   r*   d   )r   r1   r2   r3   r   rZ   r   )r7   r8   r   r   r   rN   r   r   r   check_add_gufunc(  s   

z#TestGUVectorizeJit.check_add_gufuncc                 C   &   t dd| jddd }| | d S )Nint64[:], int64, int64[:]r^   r>   c                 S   (   t | jd D ]
}| | | ||< qd S r   rL   r`   r   r   r   r@   4  ra   z/TestGUVectorizeJit.test_add_static.<locals>.addr   r?   r   r7   r@   r   r   r   test_add_static3  s
   
z"TestGUVectorizeJit.test_add_staticc                 C   r   )Nr   r^   r>   c                 S   r   r   rL   r`   r   r   r   r@   >  ra   z9TestGUVectorizeJit.test_add_static_cast_args.<locals>.addr   r   r   r   r   test_add_static_cast_args<  s
   
z,TestGUVectorizeJit.test_add_static_cast_argsc                 C   s$   t d| jddd }| | d S )Nr^   r>   c                 S   r   r   rL   r`   r   r   r   r@   G     z0TestGUVectorizeJit.test_add_dynamic.<locals>.addr   r   r   r   r   test_add_dynamicF  s   
z#TestGUVectorizeJit.test_add_dynamicc                 C   s&   t d| jdddd }| | d S )Nr^   T)r?   forceobjc                 S   r   r   rL   r`   r   r   r   r@   P  r  z0TestGUVectorizeJit.test_object_mode.<locals>.addr   r   r   r   r   test_object_modeN  s   
z#TestGUVectorizeJit.test_object_modec                 C   s   d}t j|d d t jd|dd}t j|d d t jd|dd}t j|d d t jd|dd}|||| t ||}t jj||ddd d S r%   r0   )r7   jit_funcr9   r   r   r   r:   r   r   r   check_matmulW  s   """zTestGUVectorizeJit.check_matmulc                    s6   t d| jdt tdd fdd}| | d S )Nr=   r>   Tr   c                    s    | ||S rj   r   )r   r   r   r   r   r   
matmul_jitg     z<TestGUVectorizeJit.test_njit_matmul_call.<locals>.matmul_jit)r   r?   r   r   r  )r7   r  r   r   r   test_njit_matmul_callb  s   z(TestGUVectorizeJit.test_njit_matmul_callc                    sh   t td| jdd tdd fdd}tjdtjd}t|}||||| | ||| |  d S )	Nz(),(),() -> ()Tr   r   c                        | ||| d S rj   r   r   r   r   r   axpy_jitq     z.TestGUVectorizeJit.test_axpy.<locals>.axpy_jitrF   r(   )	r
   r!   r?   r   r1   r2   rG   rZ   r   )r7   r  r   r    r   r   r   	test_axpym  s   

zTestGUVectorizeJit.test_axpyc                    s   t ddd  tdd fdd}tjdd	d
dd}tjdd	d
}tjdd	d
}|||| t|} ||| | || d S )Nz(n),(m) -> ()c                 S   s   |   |   |d< d S r   )r   r   r   r   r   r8   |  s   z5TestGUVectorizeJit.test_output_scalar.<locals>.gufuncTr   c                    r   rj   r   r   r   r   r   r    r   z7TestGUVectorizeJit.test_output_scalar.<locals>.jit_funcr   r   r(   r'   rF   rS   )r   r   r1   r2   r3   r   rZ   r   )r7   r  r   r   rN   r[   r   r   r   test_output_scalarz  s   

z%TestGUVectorizeJit.test_output_scalarc                    sv   t ddd  tdd fdd}tjdd	d
ddd}t|}||| t|} || | || d S )Nz() -> ()c                 S   s   | d |d< d S )Nr   r   r   r   rN   r   r   r   r8     r   z4TestGUVectorizeJit.test_input_scalar.<locals>.gufuncTr   c                    s    | | d S rj   r   r  r   r   r   r    s   z6TestGUVectorizeJit.test_input_scalar.<locals>.jit_funcr   r   r(   r*   r&   r'   )r   r   r1   r2   r3   rZ   r   )r7   r  r   rN   r[   r   r   r   test_input_scalar  s   




z$TestGUVectorizeJit.test_input_scalarc                    s  d}t |dd  tdd fdd}d\}}t|d	 ||}t|d
 |||}t|}t|d	 ||}| t}	t|| }
||
||| W d    n1 s^w   Y  d| d}| |t|	j	 | t}	t|| ||}||||| W d    n1 sw   Y  d| d}| |t|	j	 | t}	t
d
}||||| W d    n1 sw   Y  d| d}| |t|	j	 | t}	t|}||||| W d    n1 sw   Y  d| d}| |t|	j	 d S )Nz (n, m), (n, n, n) -> (m), (n, n)c                 S      d|d< d|d< d S N{   r   i  r   r   r   rN   r    r   r   r   bar     z9TestGUVectorizeJit.test_gufunc_ndim_mismatch.<locals>.barTr   c                    r
  rj   r   r  r  r   r   r     r  z9TestGUVectorizeJit.test_gufunc_ndim_mismatch.<locals>.foo)r&   r   r&   r   zXbar: Input operand 0 does not have enough dimensions (has 1, gufunc core with signature z requires 2)zXbar: Input operand 1 does not have enough dimensions (has 2, gufunc core with signature z requires 3)zYbar: Output operand 0 does not have enough dimensions (has 0, gufunc core with signature z requires 1)zYbar: Output operand 1 does not have enough dimensions (has 1, gufunc core with signature )r   r   r1   r2   r3   r~   r	   r   r   r   r   )r7   r   r   NMr   r   rN   r    r   x_r   y_res_out_r   r  r   test_gufunc_ndim_mismatch  sT   



z,TestGUVectorizeJit.test_gufunc_ndim_mismatchc           
            t ddd  tdd fdd}d}d	}td
d	|f}t|f}td}| t} ||| W d    n1 s@w   Y  d}| |t|j	 | t}	|||| W d    n1 sfw   Y  d}| |t|	j	 d S )N(n),(n) -> ()c                 S      d|d< d S Nr  r   r   r   r   r   r   r    r  z>TestGUVectorizeJit.test_mismatch_inner_dimensions.<locals>.barTr   c                    r   rj   r   r   r  r   r   r     r   z>TestGUVectorizeJit.test_mismatch_inner_dimensions.<locals>.foor&   r   r*   r*   r   zxInput operand 1 has a mismatch in its core dimension 0, with gufunc signature (n),(n) -> () (size 3 is different from 2)4Operand has a mismatch in one of its core dimensions
r   r   r1   emptyr   r~   
ValueErrorr   r   r   
r7   r   r  r  r   r   rN   	np_raisesr   r   r   r  r   test_mismatch_inner_dimensions  &   

z1TestGUVectorizeJit.test_mismatch_inner_dimensionsc           
         r  )Nz(n),(m) -> (n)c                 S   r!  r"  r   r   r   r   r   r    r  zKTestGUVectorizeJit.test_mismatch_inner_dimensions_input_output.<locals>.barTr   c                    r   rj   r   r   r  r   r   r     r   zKTestGUVectorizeJit.test_mismatch_inner_dimensions_input_output.<locals>.foor&   r   r*   r#  zzOutput operand 0 has a mismatch in its core dimension 0, with gufunc signature (n),(m) -> (n) (size 3 is different from 2)r$  r%  r(  r   r  r   +test_mismatch_inner_dimensions_input_output  r+  z>TestGUVectorizeJit.test_mismatch_inner_dimensions_input_outputc                    s   t ddd  tdd fdd}d}d	}t|f}t|f}t|f}t|f}| t} |||| W d    n1 sFw   Y  d
}	| |	t|j	 | t}
||||| W d    n1 smw   Y  d}	| |	t|
j	 d S )Nz(n),(m) -> (m),(m)c                 S   r  r  r   r  r   r   r   r    r  zETestGUVectorizeJit.test_mismatch_inner_dimensions_output.<locals>.barTr   c                    r
  rj   r   r  r  r   r   r     r  zETestGUVectorizeJit.test_mismatch_inner_dimensions_output.<locals>.foor&   r   z~Output operand 0 has a mismatch in its core dimension 0, with gufunc signature (n),(m) -> (m),(m) (size 2 is different from 3)r$  r%  )r7   r   r  r  r   r   rN   r    r)  r   r   r   r  r   %test_mismatch_inner_dimensions_output  s(   
z8TestGUVectorizeJit.test_mismatch_inner_dimensions_outputc                    s   t ddd  tdd fdd}d}td	d
d|f}td
d|f}td}| t}|||| W d    n1 sAw   Y  d}| |t|j	 d S )Nr   c                 S   r!  r"  r   r   r   r   r   r    r  z8TestGUVectorizeJit.test_mismatch_loop_shape.<locals>.barTr   c                    r   rj   r   r   r  r   r   r   #  r   z8TestGUVectorizeJit.test_mismatch_loop_shape.<locals>.foor&   ro   r*   r   r#  &Loop and array shapes are incompatibler%  )r7   r   r  r   r   rN   r   r   r   r  r   test_mismatch_loop_shape  s   

z+TestGUVectorizeJit.test_mismatch_loop_shapec           
         s   t ddd  t fdd}d}td| d|f}t|}td}td	|f}| t} |||| W d    n1 sFw   Y  d
}| 	|t
|j | t}	||||| W d    n1 smw   Y  d}| 	|t
|	j d S )Nz(n),(n) -> (), (n)c                 S   s@   |   |d< t| jd D ]}||  | | |   7  < qd S r   )r   r   r   )r   r   rN   r    r   r   r   r   r8   2  s   z=TestGUVectorizeJit.test_mismatch_loop_shape_2.<locals>.gufuncc                    r
  rj   r   r  r   r   r   r  8  r  z?TestGUVectorizeJit.test_mismatch_loop_shape_2.<locals>.jit_funcr&   r'   )r   r   zoperands could not be broadcast together with remapped shapes [original->remapped]: (4,2)->(4,newaxis) (2,)->() (3,)->(3,newaxis) (3,2)->(3,2)  and requested shape (2)r.  )r   r   r1   r2   r3   r&  r   r~   r'  r   r   r   )
r7   r  r  r   r   rN   r    r)  r   r   r   r   r   test_mismatch_loop_shape_21  s&   


z-TestGUVectorizeJit.test_mismatch_loop_shape_2N)rd   rc   re   r?   r   r   r   r  unittestexpectedFailurer  r  r	  r  r  r  r  r*  r,  r-  r/  r0  r   r   r   r   r   %  s&    	

.r   __main__)r1  r   numpyr1   numbar   r   r   r   r   r   r   numba.core.errorsr	   numba.np.ufuncr
   numba.tests.supportr   r   r   r!   r#   rh   r   r   r   r   r   r   rd   mainr   r   r   r   <module>   s.    $IE $]r  -