U
    iâËd-  ã                   @   sº   d dl Z d dlZd dlZd dl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T d dlZeƒ Zde_eƒ ZG dd	„ d	eƒZG d
d„ deeƒZG dd„ deeƒZedkr¶e ¡  dS )é    N)Úcompile_isolatedÚFlagsÚutils)Útypes)ÚTestCaseÚtagé   )Ú*Tc                   @   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r4|t d
ƒg7 }dd„ t ||¡D ƒS )Nç       €ç        r   éÿÿÿÿç      ø?g      Àú-infú+infÚwin32Únanc                 S   s   g | ]\}}t ||ƒ‘qS © ©Úcomplex©Ú.0ÚxÚyr   r   úQ/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numba/tests/test_complex.pyÚ
<listcomp>   s     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   s   g | ]\}}t ||ƒ‘qS r   r   r   r   r   r   r       s     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   s   g | ]\}}t ||ƒ‘qS r   r   r   r   r   r   r   %   s     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 ||g|d�}|j}	|tjtjfkr2dnd}
|D ]v}z||ƒ}W n: tk
r„ } z|  dt|ƒ¡ W Y ¢q:W 5 d }~X Y nX |	|ƒ}d||
f }| j|||
|||d� q:qd S )N©ÚflagsÚsingleÚdoubleúmath domain errorúfor input %r with prec %r)ÚprecÚulpsÚabs_tolÚmsg)	r   Úentry_pointr   Úfloat32Ú	complex64Ú
ValueErrorÚassertInÚstrÚassertPreciseEqual)r"   ÚpyfuncZx_typesZx_valuesr0   r1   r*   ÚtxÚcrÚcfuncr/   ÚvxÚexpectedÚeÚgotr2   r   r   r   Ú	run_unary'   s"    
  ÿzBaseComplexTest.run_unaryc                 C   sê   |D ]à\}}t |||g|d�}|j}	t||gƒttjtjgƒ@ rDdnd}
|D ]–\}}z|||ƒ}W nP tk
rœ } z|  dt|ƒ¡ W Y ¢qLW 5 d }~X Y n t	k
r²   Y qLY nX |	||ƒ}d||f|
f }| j
|||
||d� qLqd S )Nr)   r+   r,   r-   r.   )r/   r0   r2   )r   r3   Úsetr   r4   r5   r6   r7   r8   ÚZeroDivisionErrorr9   )r"   r:   Úvalue_typesÚvaluesr0   r*   r;   Útyr<   r=   r/   r>   Zvyr?   r@   rA   r2   r   r   r   Ú
run_binary8   s*    ÿþ


 ÿzBaseComplexTest.run_binary)	Ú__name__Ú
__module__Ú__qualname__r#   r&   r(   Úenable_pyobj_flagsrB   rH   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   s`   | j ttjtjg|  ¡ |d� | j ttjtjgdddg|d� | j ttjtj	gddg|d� d S ©Nr)   r   r   éýÿÿÿr   g      à¿)
rB   Zreal_usecaser   r5   Ú
complex128r#   Úint8Úint64r4   Úfloat64©r"   r*   r   r   r   Ú	test_realP   s     ÿ ÿ ÿzTestComplex.test_realc                 C   s   | j td� d S ©Nr)   )rU   Úno_pyobj_flags©r"   r   r   r   Útest_real_npmX   s    zTestComplex.test_real_npmc                 C   s`   | j ttjtjg|  ¡ |d� | j ttjtjgdddg|d� | j ttjtj	gddg|d� d S rN   )
rB   Zimag_usecaser   r5   rP   r#   rQ   rR   r4   rS   rT   r   r   r   Ú	test_imag[   s     ÿ ÿ ÿzTestComplex.test_imagc                 C   s   | j td� d S rV   )rZ   rW   rX   r   r   r   Útest_imag_npmc   s    zTestComplex.test_imag_npmc                 C   s`   | j ttjtjg|  ¡ |d� | j ttjtjgdddg|d� | j ttjtj	gddg|d� d S rN   )
rB   Zconjugate_usecaser   r5   rP   r#   rQ   rR   r4   rS   rT   r   r   r   Útest_conjugatef   s     ÿ ÿ ÿzTestComplex.test_conjugatec                 C   s   | j td� d S rV   )r\   rW   rX   r   r   r   Útest_conjugate_npmn   s    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.
        r)   N)	Úlistr   r    r&   r   rP   r5   rH   Zdiv_usecase©r"   r*   rF   rE   r   r   r   Útest_divq   s
    

ÿzTestComplex.test_divc                 C   s   | j td� d S rV   )r`   rW   rX   r   r   r   Útest_div_npm{   s    zTestComplex.test_div_npmN)rI   rJ   rK   rL   rU   rY   rZ   r[   r\   r]   r`   ra   r   r   r   r   rM   N   s   
rM   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   )rB   r   rP   r5   r#   )r"   r:   r*   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|p8|  ¡ |||d� d S )N)r*   r0   r1   )rB   r   rP   r&   r5   r#   )r"   r:   r*   r0   r1   rF   r   r   r   Úcheck_unary_funcˆ   s    
  þ
  þzTestCMath.check_unary_funcc                 C   s   |   tt¡ d S ©N)rd   Úphase_usecaserL   rX   r   r   r   Ú
test_phase”   s    zTestCMath.test_phasec                 C   s   |   tt¡ d S re   )rd   rf   rW   rX   r   r   r   Útest_phase_npm—   s    zTestCMath.test_phase_npmc                 C   s   |   tt¡ d S re   )rd   Úpolar_usecaserL   rX   r   r   r   Ú
test_polarš   s    zTestCMath.test_polarc                 C   s   |   tt¡ d S re   )rd   ri   rW   rX   r   r   r   Útest_polar_npm�   s    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>r)   )rH   Zrect_usecase)ÚtpZseed_valuesrF   ©r*   r"   r   r   Údo_test¡   s    z$TestCMath.test_rect.<locals>.do_test)r   rS   r&   r4   r#   )r"   r*   rr   r   rq   r   Ú	test_rect    s    zTestCMath.test_rectc                 C   s   | j td� d S rV   )rs   rW   rX   r   r   r   Útest_rect_npm©   s    zTestCMath.test_rect_npmc                 C   s   |   tt¡ d S re   )rc   Úisnan_usecaserL   rT   r   r   r   Ú
test_isnan®   s    zTestCMath.test_isnanc                 C   s   |   tt¡ d S re   )rc   ru   rW   rX   r   r   r   Útest_isnan_npm±   s    zTestCMath.test_isnan_npmc                 C   s   |   tt¡ d S re   )rc   Úisinf_usecaserL   rT   r   r   r   Ú
test_isinf´   s    zTestCMath.test_isinfc                 C   s   |   tt¡ d S re   )rc   rx   rW   rX   r   r   r   Útest_isinf_npm·   s    zTestCMath.test_isinf_npmc                 C   s   |   tt¡ d S re   )rc   Úisfinite_usecaserL   rT   r   r   r   Útest_isfiniteº   s    zTestCMath.test_isfinitec                 C   s   |   tt¡ d S re   )rc   r{   rW   rX   r   r   r   Útest_isfinite_npm½   s    zTestCMath.test_isfinite_npmc                 C   s   | j ttdd� d S ©Né   )r0   )rd   Úexp_usecaserL   rX   r   r   r   Útest_expÂ   s    zTestCMath.test_expc                 C   s   | j ttdd� d S r~   )rd   r€   rW   rX   r   r   r   Útest_exp_npmÅ   s    zTestCMath.test_exp_npmc                 C   s   |   tt¡ d S re   )rd   Úlog_usecaserL   rX   r   r   r   Útest_logË   s    zTestCMath.test_logc                 C   s   |   tt¡ d S re   )rd   rƒ   rW   rX   r   r   r   Útest_log_npmÎ   s    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é   )r*   r0   )	r^   r   r    r&   r   rP   r5   rH   Zlog_base_usecaser_   r   r   r   Útest_log_baseÑ   s    

ÿÿzTestCMath.test_log_basec                 C   s   | j td� d S rV   )r‡   rW   rX   r   r   r   Útest_log_base_npmØ   s    zTestCMath.test_log_base_npmc                 C   s   |   tt¡ d S re   )rd   Úlog10_usecaserL   rX   r   r   r   Ú
test_log10Û   s    zTestCMath.test_log10c                 C   s   |   tt¡ d S re   )rd   r‰   rW   rX   r   r   r   Útest_log10_npmÞ   s    zTestCMath.test_log10_npmc                 C   s   |   tt¡ d S re   )rd   Úsqrt_usecaserL   rX   r   r   r   Ú	test_sqrtá   s    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>é$   é)   r)   )rd   rŒ   rW   ÚrangerB   r   rP   )r"   rF   r   r   r   Útest_sqrt_npmä   s     ÿzTestCMath.test_sqrt_npmc                 C   s   | j ttdd� d S r~   )rd   Úacos_usecaserL   rX   r   r   r   Ú	test_acosî   s    zTestCMath.test_acosc                 C   s   | j ttdd� d S r~   )rd   r”   rW   rX   r   r   r   Útest_acos_npmñ   s    zTestCMath.test_acos_npmc                 C   s   | j ttdd� d S r~   )rd   Úasin_usecaserL   rX   r   r   r   Ú	test_asinô   s    zTestCMath.test_asinc                 C   s   | j ttdd� d S r~   )rd   r—   rW   rX   r   r   r   Útest_asin_npm÷   s    zTestCMath.test_asin_npmc                 C   s   | j ttdd� d S r~   )rd   Úatan_usecaserL   rX   r   r   r   Ú	test_atanú   s    zTestCMath.test_atanc                 C   s   | j ttdd� d S r~   )rd   rš   rW   rX   r   r   r   Útest_atan_npmý   s    zTestCMath.test_atan_npmc                 C   s   | j ttdd� d S r~   )rd   Úcos_usecaserL   rX   r   r   r   Útest_cos   s    zTestCMath.test_cosc                 C   s   | j ttdd� d S r~   )rd   r�   rW   rX   r   r   r   Útest_cos_npm  s    zTestCMath.test_cos_npmc                 C   s   | j ttdd� d S ©NZeps)r1   )rd   Úsin_usecaserL   rX   r   r   r   Útest_sin  s    zTestCMath.test_sinc                 C   s   | j ttdd� d S r    )rd   r¡   rW   rX   r   r   r   Útest_sin_npm
  s    zTestCMath.test_sin_npmc                 C   s   | j ttdd� d S r~   ©rd   Ztan_usecaserL   rX   r   r   r   Útest_tan  s    zTestCMath.test_tanc                 C   s   | j ttdd� d S r~   r¤   rX   r   r   r   Útest_tan_npm  s    zTestCMath.test_tan_npmc                 C   s   |   tt¡ d S re   )rd   Úacosh_usecaserL   rX   r   r   r   Ú
test_acosh  s    zTestCMath.test_acoshc                 C   s   |   tt¡ d S re   )rd   r§   rW   rX   r   r   r   Útest_acosh_npm  s    zTestCMath.test_acosh_npmc                 C   s   | j ttdd� d S r~   )rd   Úasinh_usecaserL   rX   r   r   r   Ú
test_asinh  s    zTestCMath.test_asinhc                 C   s   | j ttdd� d S r~   )rd   rª   rW   rX   r   r   r   Útest_asinh_npm  s    zTestCMath.test_asinh_npmc                 C   s   | j ttdd� d S r~   )rd   Úatanh_usecaserL   rX   r   r   r   Ú
test_atanh!  s    zTestCMath.test_atanhc                 C   s   | j ttdd� d S r~   )rd   r­   rW   rX   r   r   r   Útest_atanh_npm$  s    zTestCMath.test_atanh_npmc                 C   s   | j ttdd� d S r~   )rd   Úcosh_usecaserL   rX   r   r   r   Ú	test_cosh'  s    zTestCMath.test_coshc                 C   s   | j ttdd� d S r~   )rd   r°   rW   rX   r   r   r   Útest_cosh_npm*  s    zTestCMath.test_cosh_npmc                 C   s   | j ttdd� d S r    )rd   Úsinh_usecaserL   rX   r   r   r   Ú	test_sinh-  s    zTestCMath.test_sinhc                 C   s   | j ttdd� d S r    )rd   r³   rW   rX   r   r   r   Útest_sinh_npm0  s    zTestCMath.test_sinh_npmc                 C   s   | j ttdd� d S r~   ©rd   Ztanh_usecaserL   rX   r   r   r   Ú	test_tanh3  s    zTestCMath.test_tanhc                 C   s   | j ttdd� d S r~   r¶   rX   r   r   r   Útest_tanh_npm6  s    zTestCMath.test_tanh_npm)r   NN)5rI   rJ   rK   Ú__doc__rc   rd   rg   rh   rj   rk   rL   rs   rt   rv   rw   ry   rz   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   rb      sf     ÿ
	
rb   Ú__main__)Zcmathr   r$   r   Znumba.core.compilerr   r   r   Z
numba.corer   Znumba.tests.supportr   r   Zcomplex_usecasesZunittestrL   Zenable_pyobjectrW   Úobjectr
   rM   rb   rI   Úmainr   r   r   r   Ú<module>   s"   <1 <