o
    i-                     @   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 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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   g/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/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 ||g|d}|j}	|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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_valuesr2   r3   r,   txcrcfuncr1   vxexpectedegotr4   r   r   r   	run_unary'   s&   
zBaseComplexTest.run_unaryc                 C   s   |D ]j\}}t |||g|d}|j}	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/   r0   )r1   r2   r4   )r   r5   setr   r6   r7   r8   r9   r:   ZeroDivisionErrorr;   )r$   r<   value_typesvaluesr2   r,   r=   tyr>   r?   r1   r@   ZvyrA   rB   rC   r4   r   r   r   
run_binary8   s0   

zBaseComplexTest.run_binary)	__name__
__module____qualname__r%   r(   r*   enable_pyobj_flagsrD   rJ   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 Nr+   )r   r   r   g      )
rD   Zreal_usecaser   r7   
complex128r%   int8int64r6   float64r$   r,   r   r   r   	test_realP      
zTestComplex.test_realc                 C      | j td d S Nr+   )rX   no_pyobj_flagsr$   r   r   r   test_real_npmX      zTestComplex.test_real_npmc                 C   rP   rQ   )
rD   Zimag_usecaser   r7   rS   r%   rT   rU   r6   rV   rW   r   r   r   	test_imag[   rY   zTestComplex.test_imagc                 C   rZ   r[   )r`   r\   r]   r   r   r   test_imag_npmc   r_   zTestComplex.test_imag_npmc                 C   rP   rQ   )
rD   Zconjugate_usecaser   r7   rS   r%   rT   rU   r6   rV   rW   r   r   r   test_conjugatef   rY   zTestComplex.test_conjugatec                 C   rZ   r[   )rb   r\   r]   r   r   r   test_conjugate_npmn   r_   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   rS   r7   rJ   Zdiv_usecaser$   r,   rH   rG   r   r   r   test_divq   s
   

zTestComplex.test_divc                 C   rZ   r[   )rf   r\   r]   r   r   r   test_div_npm{   r_   zTestComplex.test_div_npmN)rK   rL   rM   rN   rX   r^   r`   ra   rb   rc   rf   rg   r   r   r   r   rO   N   s    
rO   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 r[   )rD   r   rS   r7   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|p|  |||d d S )N)r,   r2   r3   )rD   r   rS   r(   r7   r%   )r$   r<   r,   r2   r3   rH   r   r   r   check_unary_func   s   
zTestCMath.check_unary_funcc                 C      |  tt d S N)rj   phase_usecaserN   r]   r   r   r   
test_phase   r_   zTestCMath.test_phasec                 C   rk   rl   )rj   rm   r\   r]   r   r   r   test_phase_npm   r_   zTestCMath.test_phase_npmc                 C   rk   rl   )rj   polar_usecaserN   r]   r   r   r   
test_polar   r_   zTestCMath.test_polarc                 C   rk   rl   )rj   rp   r\   r]   r   r   r   test_polar_npm   r_   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+   )rJ   Zrect_usecase)tpZseed_valuesrH   r,   r$   r   r   do_test   s   z$TestCMath.test_rect.<locals>.do_test)r   rV   r(   r6   r%   )r$   r,   ry   r   rx   r   	test_rect   s   zTestCMath.test_rectc                 C   rZ   r[   )rz   r\   r]   r   r   r   test_rect_npm   r_   zTestCMath.test_rect_npmc                 C   rk   rl   )ri   isnan_usecaserN   rW   r   r   r   
test_isnan   r_   zTestCMath.test_isnanc                 C   rk   rl   )ri   r|   r\   r]   r   r   r   test_isnan_npm   r_   zTestCMath.test_isnan_npmc                 C   rk   rl   )ri   isinf_usecaserN   rW   r   r   r   
test_isinf   r_   zTestCMath.test_isinfc                 C   rk   rl   )ri   r   r\   r]   r   r   r   test_isinf_npm   r_   zTestCMath.test_isinf_npmc                 C   rk   rl   )ri   isfinite_usecaserN   rW   r   r   r   test_isfinite   r_   zTestCMath.test_isfinitec                 C   rk   rl   )ri   r   r\   r]   r   r   r   test_isfinite_npm   r_   zTestCMath.test_isfinite_npmc                 C      | j ttdd d S N   )r2   )rj   exp_usecaserN   r]   r   r   r   test_exp      zTestCMath.test_expc                 C   r   r   )rj   r   r\   r]   r   r   r   test_exp_npm   s   zTestCMath.test_exp_npmc                 C   rk   rl   )rj   log_usecaserN   r]   r   r   r   test_log   r_   zTestCMath.test_logc                 C   rk   rl   )rj   r   r\   r]   r   r   r   test_log_npm   r_   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,   r2   )	rd   r!   r"   r(   r   rS   r7   rJ   Zlog_base_usecasere   r   r   r   test_log_base   s   


zTestCMath.test_log_basec                 C   rZ   r[   )r   r\   r]   r   r   r   test_log_base_npm   r_   zTestCMath.test_log_base_npmc                 C   rk   rl   )rj   log10_usecaserN   r]   r   r   r   
test_log10   r_   zTestCMath.test_log10c                 C   rk   rl   )rj   r   r\   r]   r   r   r   test_log10_npm   r_   zTestCMath.test_log10_npmc                 C   rk   rl   )rj   sqrt_usecaserN   r]   r   r   r   	test_sqrt   r_   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+   )rj   r   r\   rangerD   r   rS   )r$   rH   r   r   r   test_sqrt_npm   s
   
zTestCMath.test_sqrt_npmc                 C   r   r   )rj   acos_usecaserN   r]   r   r   r   	test_acos   r   zTestCMath.test_acosc                 C   r   r   )rj   r   r\   r]   r   r   r   test_acos_npm   r   zTestCMath.test_acos_npmc                 C   r   r   )rj   asin_usecaserN   r]   r   r   r   	test_asin   r   zTestCMath.test_asinc                 C   r   r   )rj   r   r\   r]   r   r   r   test_asin_npm   r   zTestCMath.test_asin_npmc                 C   r   r   )rj   atan_usecaserN   r]   r   r   r   	test_atan   r   zTestCMath.test_atanc                 C   r   r   )rj   r   r\   r]   r   r   r   test_atan_npm   r   zTestCMath.test_atan_npmc                 C   r   r   )rj   cos_usecaserN   r]   r   r   r   test_cos   r   zTestCMath.test_cosc                 C   r   r   )rj   r   r\   r]   r   r   r   test_cos_npm  r   zTestCMath.test_cos_npmc                 C   r   NZeps)r3   )rj   sin_usecaserN   r]   r   r   r   test_sin  s   zTestCMath.test_sinc                 C   r   r   )rj   r   r\   r]   r   r   r   test_sin_npm
  r   zTestCMath.test_sin_npmc                 C   r   r   rj   Ztan_usecaserN   r]   r   r   r   test_tan  r   zTestCMath.test_tanc                 C   r   r   r   r]   r   r   r   test_tan_npm  r   zTestCMath.test_tan_npmc                 C   rk   rl   )rj   acosh_usecaserN   r]   r   r   r   
test_acosh  r_   zTestCMath.test_acoshc                 C   rk   rl   )rj   r   r\   r]   r   r   r   test_acosh_npm  r_   zTestCMath.test_acosh_npmc                 C   r   r   )rj   asinh_usecaserN   r]   r   r   r   
test_asinh  r   zTestCMath.test_asinhc                 C   r   r   )rj   r   r\   r]   r   r   r   test_asinh_npm  r   zTestCMath.test_asinh_npmc                 C   r   r   )rj   atanh_usecaserN   r]   r   r   r   
test_atanh!  r   zTestCMath.test_atanhc                 C   r   r   )rj   r   r\   r]   r   r   r   test_atanh_npm$  r   zTestCMath.test_atanh_npmc                 C   r   r   )rj   cosh_usecaserN   r]   r   r   r   	test_cosh'  r   zTestCMath.test_coshc                 C   r   r   )rj   r   r\   r]   r   r   r   test_cosh_npm*  r   zTestCMath.test_cosh_npmc                 C   r   r   )rj   sinh_usecaserN   r]   r   r   r   	test_sinh-  r   zTestCMath.test_sinhc                 C   r   r   )rj   r   r\   r]   r   r   r   test_sinh_npm0  r   zTestCMath.test_sinh_npmc                 C   r   r   rj   Ztanh_usecaserN   r]   r   r   r   	test_tanh3  r   zTestCMath.test_tanhc                 C   r   r   r   r]   r   r   r   test_tanh_npm6  r   zTestCMath.test_tanh_npm)r   NN)5rK   rL   rM   __doc__ri   rj   rn   ro   rq   rr   rN   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   r   r   r   r   r   rh      sh    
	
rh   __main__)Zcmathr!   r&   r   Znumba.core.compilerr   r   r   Z
numba.corer   Znumba.tests.supportr   r   Zcomplex_usecasesZunittestrN   Zenable_pyobjectr\   objectr
   rO   rh   rK   mainr   r   r   r   <module>   s&    <1 <