o
    i=,                     @   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   )*forceobjT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   U/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/numba/tests/test_complex.py
<listcomp>       z0BaseComplexTest.basic_values.<locals>.<listcomp>)floatsysplatform	itertoolsproductself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#   pyfuncx_typesx_valuesr0   r1   flagstxcfuncr/   vxexpectedegotr2   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/   r0   r2   )
r   setr   r3   r4   r5   r6   r7   ZeroDivisionErrorr8   )r#   r9   value_typesvaluesr0   r<   r=   tyr>   r/   r?   vyr@   rA   rB   r2   r   r   r   
run_binary3   s.   

zBaseComplexTest.run_binary)	__name__
__module____qualname__r%   r(   r*   enable_pyobj_flagsrC   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 Nr<   )r   r   r   g      )
rC   real_usecaser   r4   
complex128r%   int8int64r3   float64r#   r<   r   r   r   	test_realJ      
zTestComplex.test_realc                 C      | j td d S NrR   )rZ   no_pyobj_flagsr#   r   r   r   test_real_npmR      zTestComplex.test_real_npmc                 C   rP   rQ   )
rC   imag_usecaser   r4   rU   r%   rV   rW   r3   rX   rY   r   r   r   	test_imagU   r[   zTestComplex.test_imagc                 C   r\   r]   )rc   r^   r_   r   r   r   test_imag_npm]   ra   zTestComplex.test_imag_npmc                 C   rP   rQ   )
rC   conjugate_usecaser   r4   rU   r%   rV   rW   r3   rX   rY   r   r   r   test_conjugate`   r[   zTestComplex.test_conjugatec                 C   r\   r]   )rf   r^   r_   r   r   r   test_conjugate_npmh   ra   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.
        rR   N)	listr    r!   r(   r   rU   r4   rJ   div_usecaser#   r<   rG   rF   r   r   r   test_divk   s
   

zTestComplex.test_divc                 C   r\   r]   )rk   r^   r_   r   r   r   test_div_npmu   ra   zTestComplex.test_div_npmN)rK   rL   rM   rN   rZ   r`   rc   rd   rf   rg   rk   rl   r   r   r   r   rO   H   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]   )rC   r   rU   r4   r%   )r#   r9   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<   r0   r1   )rC   r   rU   r(   r4   r%   )r#   r9   r<   r0   r1   rG   r   r   r   check_unary_func   s   
zTestCMath.check_unary_funcc                 C      |  tt d S N)ro   phase_usecaserN   r_   r   r   r   
test_phase   ra   zTestCMath.test_phasec                 C   rp   rq   )ro   rr   r^   r_   r   r   r   test_phase_npm   ra   zTestCMath.test_phase_npmc                 C   rp   rq   )ro   polar_usecaserN   r_   r   r   r   
test_polar   ra   zTestCMath.test_polarc                 C   rp   rq   )ro   ru   r^   r_   r   r   r   test_polar_npm   ra   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>rR   )rJ   rect_usecase)tpseed_valuesrG   r<   r#   r   r   do_test   s   z$TestCMath.test_rect.<locals>.do_test)r   rX   r(   r3   r%   )r#   r<   r   r   r   r   	test_rect   s   zTestCMath.test_rectc                 C   r\   r]   )r   r^   r_   r   r   r   test_rect_npm   ra   zTestCMath.test_rect_npmc                 C   rp   rq   )rn   isnan_usecaserN   rY   r   r   r   
test_isnan   ra   zTestCMath.test_isnanc                 C   rp   rq   )rn   r   r^   r_   r   r   r   test_isnan_npm   ra   zTestCMath.test_isnan_npmc                 C   rp   rq   )rn   isinf_usecaserN   rY   r   r   r   
test_isinf   ra   zTestCMath.test_isinfc                 C   rp   rq   )rn   r   r^   r_   r   r   r   test_isinf_npm   ra   zTestCMath.test_isinf_npmc                 C   rp   rq   )rn   isfinite_usecaserN   rY   r   r   r   test_isfinite   ra   zTestCMath.test_isfinitec                 C   rp   rq   )rn   r   r^   r_   r   r   r   test_isfinite_npm   ra   zTestCMath.test_isfinite_npmc                 C      | j ttdd d S N   )r0   )ro   exp_usecaserN   r_   r   r   r   test_exp      zTestCMath.test_expc                 C   r   r   )ro   r   r^   r_   r   r   r   test_exp_npm   s   zTestCMath.test_exp_npmc                 C   rp   rq   )ro   log_usecaserN   r_   r   r   r   test_log   ra   zTestCMath.test_logc                 C   rp   rq   )ro   r   r^   r_   r   r   r   test_log_npm   ra   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   )	rh   r    r!   r(   r   rU   r4   rJ   log_base_usecaserj   r   r   r   test_log_base   s   


zTestCMath.test_log_basec                 C   r\   r]   )r   r^   r_   r   r   r   test_log_base_npm   ra   zTestCMath.test_log_base_npmc                 C   rp   rq   )ro   log10_usecaserN   r_   r   r   r   
test_log10   ra   zTestCMath.test_log10c                 C   rp   rq   )ro   r   r^   r_   r   r   r   test_log10_npm   ra   zTestCMath.test_log10_npmc                 C   rp   rq   )ro   sqrt_usecaserN   r_   r   r   r   	test_sqrt   ra   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>$   )   rR   )ro   r   r^   rangerC   r   rU   )r#   rG   r   r   r   test_sqrt_npm   s
   
zTestCMath.test_sqrt_npmc                 C   r   r   )ro   acos_usecaserN   r_   r   r   r   	test_acos   r   zTestCMath.test_acosc                 C   r   r   )ro   r   r^   r_   r   r   r   test_acos_npm   r   zTestCMath.test_acos_npmc                 C   r   r   )ro   asin_usecaserN   r_   r   r   r   	test_asin   r   zTestCMath.test_asinc                 C   r   r   )ro   r   r^   r_   r   r   r   test_asin_npm   r   zTestCMath.test_asin_npmc                 C   r   r   )ro   atan_usecaserN   r_   r   r   r   	test_atan   r   zTestCMath.test_atanc                 C   r   r   )ro   r   r^   r_   r   r   r   test_atan_npm   r   zTestCMath.test_atan_npmc                 C   r   r   )ro   cos_usecaserN   r_   r   r   r   test_cos   r   zTestCMath.test_cosc                 C   r   r   )ro   r   r^   r_   r   r   r   test_cos_npm   r   zTestCMath.test_cos_npmc                 C   r   Neps)r1   )ro   sin_usecaserN   r_   r   r   r   test_sin   s   zTestCMath.test_sinc                 C   r   r   )ro   r   r^   r_   r   r   r   test_sin_npm  r   zTestCMath.test_sin_npmc                 C   r   r   ro   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   rp   rq   )ro   acosh_usecaserN   r_   r   r   r   
test_acosh  ra   zTestCMath.test_acoshc                 C   rp   rq   )ro   r   r^   r_   r   r   r   test_acosh_npm  ra   zTestCMath.test_acosh_npmc                 C   r   r   )ro   asinh_usecaserN   r_   r   r   r   
test_asinh  r   zTestCMath.test_asinhc                 C   r   r   )ro   r   r^   r_   r   r   r   test_asinh_npm  r   zTestCMath.test_asinh_npmc                 C   r   r   )ro   atanh_usecaserN   r_   r   r   r   
test_atanh  r   zTestCMath.test_atanhc                 C   r   r   )ro   r   r^   r_   r   r   r   test_atanh_npm  r   zTestCMath.test_atanh_npmc                 C   r   r   )ro   cosh_usecaserN   r_   r   r   r   	test_cosh!  r   zTestCMath.test_coshc                 C   r   r   )ro   r   r^   r_   r   r   r   test_cosh_npm$  r   zTestCMath.test_cosh_npmc                 C   r   r   )ro   sinh_usecaserN   r_   r   r   r   	test_sinh'  r   zTestCMath.test_sinhc                 C   r   r   )ro   r   r^   r_   r   r   r   test_sinh_npm*  r   zTestCMath.test_sinh_npmc                 C   r   r   ro   tanh_usecaserN   r_   r   r   r   	test_tanh-  r   zTestCMath.test_tanhc                 C   r   r   r   r_   r   r   r   test_tanh_npm0  r   zTestCMath.test_tanh_npm)r   NN)5rK   rL   rM   __doc__rn   ro   rs   rt   rv   rw   rN   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   r   rm   y   sh    
	
rm   __main__)r    r&   r   numbar   r   numba.tests.supportr   complex_usecasesunittestrN   r^   objectr	   rO   rm   rK   mainr   r   r   r   <module>   s     :1 <