o
    1&ir-                     @   s   d dl Z d dlZd dlZd dlmZmZ d dlmZ ddlT d dl	Z	ddiZ
ddiZG d	d
 d
eZG dd deeZG dd deeZedkrNe	  dS dS )    N)jittypes)TestCase   )*ZforceobjTZnopythonc                   @   sB   e Zd Zdd Zdd Zdd Zddefd	d
ZdefddZdS )BaseComplexTestc              	   C   sJ   ddddddt dt dg}tjd	kr|t d
g7 }dd t||D S )N               r         ?g      -inf+infwin32nanc                 S      g | ]	\}}t ||qS  complex.0xyr   r   CC:\wamp64\www\opt\env\Lib\site-packages\numba/tests/test_complex.py
<listcomp>       z0BaseComplexTest.basic_values.<locals>.<listcomp>)floatsysplatform	itertoolsproductselfZrealsr   r   r   basic_values   s   
zBaseComplexTest.basic_valuesc              	   C   sR   ddddt j t j
 tdtdg}tjdkr|tdg7 }d	d
 t||D S )Nr   r	   r   r
   r   r   r   r   c                 S   r   r   r   r   r   r   r   r      r   z/BaseComplexTest.more_values.<locals>.<listcomp>)mathpir   r   r   r   r   r    r   r   r   more_values   s   
zBaseComplexTest.more_valuesc              	   C   s:   ddddt j t j
 tdtdg}dd t||D S )	Nr   r	   r   r
   infr   c                 S   r   r   r   r   r   r   r   r   !   r   z2BaseComplexTest.non_nan_values.<locals>.<listcomp>)r#   r$   r   r   r   r    r   r   r   non_nan_values   s   zBaseComplexTest.non_nan_valuesr   Nc                 C   s   |D ]T}t |ffi ||}|tjtjfv rdnd}	|D ]8}
z||
}W n ty? } z| dt| W Y d }~qd }~ww ||
}d|
|	f }| j|||	|||d qqd S )Nsingledoublemath domain errorfor input %r with prec %r)preculpsabs_tolmsg)r   r   float32	complex64
ValueErrorassertInstrassertPreciseEqual)r!   pyfuncZx_typesZx_valuesr-   r.   flagstxcfuncr,   vxexpectedegotr/   r   r   r   	run_unary#   s$   
zBaseComplexTest.run_unaryc                 C   s   |D ]j\}}t ||ffi ||}t||gttjtjg@ r"dnd}	|D ]E\}
}z||
|}W n" tyK } z| dt| W Y d }~q&d }~w tyS   Y q&w ||
|}d|
|f|	f }| j	|||	||d q&qd S )Nr(   r)   r*   r+   )r,   r-   r/   )
r   setr   r0   r1   r2   r3   r4   ZeroDivisionErrorr5   )r!   r6   value_typesvaluesr-   r7   r8   tyr9   r,   r:   Zvyr;   r<   r=   r/   r   r   r   
run_binary3   s.   

zBaseComplexTest.run_binary)	__name__
__module____qualname__r"   r%   r'   enable_pyobj_flagsr>   rD   r   r   r   r   r      s    
r   c                   @   s\   e Zd ZefddZdd ZefddZdd Zefd	d
Zdd Z	efddZ
dd ZdS )TestComplexc                 C   ^   | j ttjtjg|  |d | j ttjtjgg d|d | j ttjtj	gddg|d d S Nr7   )r   r   r   g      )
r>   Zreal_usecaser   r1   
complex128r"   int8int64r0   float64r!   r7   r   r   r   	test_realJ      
zTestComplex.test_realc                 C      | j td d S NrL   )rS   no_pyobj_flagsr!   r   r   r   test_real_npmR      zTestComplex.test_real_npmc                 C   rJ   rK   )
r>   Zimag_usecaser   r1   rN   r"   rO   rP   r0   rQ   rR   r   r   r   	test_imagU   rT   zTestComplex.test_imagc                 C   rU   rV   )r[   rW   rX   r   r   r   test_imag_npm]   rZ   zTestComplex.test_imag_npmc                 C   rJ   rK   )
r>   Zconjugate_usecaser   r1   rN   r"   rO   rP   r0   rQ   rR   r   r   r   test_conjugate`   rT   zTestComplex.test_conjugatec                 C   rU   rV   )r]   rW   rX   r   r   r   test_conjugate_npmh   rZ   zTestComplex.test_conjugate_npmc                 C   sF   t t|  |  }tjtjftjtjfg}| jt|||d dS )zN
        Test complex.__div__ implementation with non-trivial values.
        rL   N)	listr   r   r%   r   rN   r1   rD   Zdiv_usecaser!   r7   rB   rA   r   r   r   test_divk   s
   

zTestComplex.test_divc                 C   rU   rV   )ra   rW   rX   r   r   r   test_div_npmu   rZ   zTestComplex.test_div_npmN)rE   rF   rG   rH   rS   rY   r[   r\   r]   r^   ra   rb   r   r   r   r   rI   H   s    
rI   c                   @   s  e Zd ZdZdd Z		ddddZdd	 Zd
d Zdd Zdd Z	e
fddZdd Ze
fddZdd Ze
fddZdd Ze
fddZdd Zd d! Zd"d# Zd$d% Zd&d' Ze
fd(d)Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Z d<d= Z!d>d? Z"d@dA Z#dBdC Z$dDdE Z%dFdG Z&dHdI Z'dJdK Z(dLdM Z)dNdO Z*dPdQ Z+dRdS Z,dTdU Z-dVdW Z.dXdY Z/dZd[ Z0d\d] Z1d^d_ Z2d`da Z3dbdc Z4dS )e	TestCMathz)
    Tests for cmath module support.
    c                 C   s"   | j |tjtjg|  |d d S rV   )r>   r   rN   r1   r"   )r!   r6   r7   r   r   r   check_predicate_func~   s   
zTestCMath.check_predicate_funcr   Nc                 C   sH   | j |tjg|p|  |||d | j |tjg|p|  |||d d S )N)r7   r-   r.   )r>   r   rN   r%   r1   r"   )r!   r6   r7   r-   r.   rB   r   r   r   check_unary_func   s   
zTestCMath.check_unary_funcc                 C      |  tt d S N)re   phase_usecaserH   rX   r   r   r   
test_phase   rZ   zTestCMath.test_phasec                 C   rf   rg   )re   rh   rW   rX   r   r   r   test_phase_npm   rZ   zTestCMath.test_phase_npmc                 C   rf   rg   )re   polar_usecaserH   rX   r   r   r   
test_polar   rZ   zTestCMath.test_polarc                 C   rf   rg   )re   rk   rW   rX   r   r   r   test_polar_npm   rZ   zTestCMath.test_polar_npmc                    s2    fdd}|t j  |t j  d S )Nc                    s*   dd |D }j t| | fg| d d S )Nc                 S   s.   g | ]}t |jr|jd kr|j|jfqS )r   )r#   isinfimagreal)r   zr   r   r   r      s    


z8TestCMath.test_rect.<locals>.do_test.<locals>.<listcomp>rL   )rD   Zrect_usecase)tpZseed_valuesrB   r7   r!   r   r   do_test   s   z$TestCMath.test_rect.<locals>.do_test)r   rQ   r%   r0   r"   )r!   r7   rt   r   rs   r   	test_rect   s   zTestCMath.test_rectc                 C   rU   rV   )ru   rW   rX   r   r   r   test_rect_npm   rZ   zTestCMath.test_rect_npmc                 C   rf   rg   )rd   isnan_usecaserH   rR   r   r   r   
test_isnan   rZ   zTestCMath.test_isnanc                 C   rf   rg   )rd   rw   rW   rX   r   r   r   test_isnan_npm   rZ   zTestCMath.test_isnan_npmc                 C   rf   rg   )rd   isinf_usecaserH   rR   r   r   r   
test_isinf   rZ   zTestCMath.test_isinfc                 C   rf   rg   )rd   rz   rW   rX   r   r   r   test_isinf_npm   rZ   zTestCMath.test_isinf_npmc                 C   rf   rg   )rd   isfinite_usecaserH   rR   r   r   r   test_isfinite   rZ   zTestCMath.test_isfinitec                 C   rf   rg   )rd   r}   rW   rX   r   r   r   test_isfinite_npm   rZ   zTestCMath.test_isfinite_npmc                 C      | j ttdd d S N   )r-   )re   exp_usecaserH   rX   r   r   r   test_exp      zTestCMath.test_expc                 C   r   r   )re   r   rW   rX   r   r   r   test_exp_npm   s   zTestCMath.test_exp_npmc                 C   rf   rg   )re   log_usecaserH   rX   r   r   r   test_log   rZ   zTestCMath.test_logc                 C   rf   rg   )re   r   rW   rX   r   r   r   test_log_npm   rZ   zTestCMath.test_log_npmc                 C   sH   t t|  |  }tjtjftjtjfg}| jt|||dd d S )N   )r7   r-   )	r_   r   r   r%   r   rN   r1   rD   Zlog_base_usecaser`   r   r   r   test_log_base   s   


zTestCMath.test_log_basec                 C   rU   rV   )r   rW   rX   r   r   r   test_log_base_npm   rZ   zTestCMath.test_log_base_npmc                 C   rf   rg   )re   log10_usecaserH   rX   r   r   r   
test_log10   rZ   zTestCMath.test_log10c                 C   rf   rg   )re   r   rW   rX   r   r   r   test_log10_npm   rZ   zTestCMath.test_log10_npmc                 C   rf   rg   )re   sqrt_usecaserH   rX   r   r   r   	test_sqrt   rZ   zTestCMath.test_sqrtc                 C   s:   |  tt dd tddD }| jttjg|td d S )Nc                 S   s   g | ]}d |  qS )
   r   )r   ir   r   r   r      s    z+TestCMath.test_sqrt_npm.<locals>.<listcomp>$   )   rL   )re   r   rW   ranger>   r   rN   )r!   rB   r   r   r   test_sqrt_npm   s
   
zTestCMath.test_sqrt_npmc                 C   r   r   )re   acos_usecaserH   rX   r   r   r   	test_acos   r   zTestCMath.test_acosc                 C   r   r   )re   r   rW   rX   r   r   r   test_acos_npm   r   zTestCMath.test_acos_npmc                 C   r   r   )re   asin_usecaserH   rX   r   r   r   	test_asin   r   zTestCMath.test_asinc                 C   r   r   )re   r   rW   rX   r   r   r   test_asin_npm   r   zTestCMath.test_asin_npmc                 C   r   r   )re   atan_usecaserH   rX   r   r   r   	test_atan   r   zTestCMath.test_atanc                 C   r   r   )re   r   rW   rX   r   r   r   test_atan_npm   r   zTestCMath.test_atan_npmc                 C   r   r   )re   cos_usecaserH   rX   r   r   r   test_cos   r   zTestCMath.test_cosc                 C   r   r   )re   r   rW   rX   r   r   r   test_cos_npm   r   zTestCMath.test_cos_npmc                 C   r   NZeps)r.   )re   sin_usecaserH   rX   r   r   r   test_sin   s   zTestCMath.test_sinc                 C   r   r   )re   r   rW   rX   r   r   r   test_sin_npm  r   zTestCMath.test_sin_npmc                 C   r   r   re   Ztan_usecaserH   rX   r   r   r   test_tan  r   zTestCMath.test_tanc                 C   r   r   r   rX   r   r   r   test_tan_npm
  r   zTestCMath.test_tan_npmc                 C   rf   rg   )re   acosh_usecaserH   rX   r   r   r   
test_acosh  rZ   zTestCMath.test_acoshc                 C   rf   rg   )re   r   rW   rX   r   r   r   test_acosh_npm  rZ   zTestCMath.test_acosh_npmc                 C   r   r   )re   asinh_usecaserH   rX   r   r   r   
test_asinh  r   zTestCMath.test_asinhc                 C   r   r   )re   r   rW   rX   r   r   r   test_asinh_npm  r   zTestCMath.test_asinh_npmc                 C   r   r   )re   atanh_usecaserH   rX   r   r   r   
test_atanh  r   zTestCMath.test_atanhc                 C   r   r   )re   r   rW   rX   r   r   r   test_atanh_npm  r   zTestCMath.test_atanh_npmc                 C   r   r   )re   cosh_usecaserH   rX   r   r   r   	test_cosh!  r   zTestCMath.test_coshc                 C   r   r   )re   r   rW   rX   r   r   r   test_cosh_npm$  r   zTestCMath.test_cosh_npmc                 C   r   r   )re   sinh_usecaserH   rX   r   r   r   	test_sinh'  r   zTestCMath.test_sinhc                 C   r   r   )re   r   rW   rX   r   r   r   test_sinh_npm*  r   zTestCMath.test_sinh_npmc                 C   r   r   re   Ztanh_usecaserH   rX   r   r   r   	test_tanh-  r   zTestCMath.test_tanhc                 C   r   r   r   rX   r   r   r   test_tanh_npm0  r   zTestCMath.test_tanh_npm)r   NN)5rE   rF   rG   __doc__rd   re   ri   rj   rl   rm   rH   ru   rv   rx   ry   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   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rc   y   sh    
	
rc   __main__)r   r#   r   Znumbar   r   Znumba.tests.supportr   Zcomplex_usecasesZunittestrH   rW   objectr   rI   rc   rE   mainr   r   r   r   <module>   s     :1 <