o
    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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rPe
  dS dS )    N)jittypes)TestCaseskip_if_py314   )*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   V/home/ubuntu/transcripts/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_valuesr1   r2   flagstxcfuncr0   vxexpectedegotr3   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/   )r0   r1   r3   )
r   setr   r4   r5   r6   r7   r8   ZeroDivisionErrorr9   )r$   r:   value_typesvaluesr1   r=   r>   tyr?   r0   r@   vyrA   rB   rC   r3   r   r   r   
run_binary3   s.   

zBaseComplexTest.run_binary)	__name__
__module____qualname__r&   r)   r+   enable_pyobj_flagsrD   rK   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
e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      )
rD   real_usecaser   r5   
complex128r&   int8int64r4   float64r$   r=   r   r   r   	test_realJ      
zTestComplex.test_realc                 C      | j td d S NrS   )r[   no_pyobj_flagsr$   r   r   r   test_real_npmR      zTestComplex.test_real_npmc                 C   rQ   rR   )
rD   imag_usecaser   r5   rV   r&   rW   rX   r4   rY   rZ   r   r   r   	test_imagU   r\   zTestComplex.test_imagc                 C   r]   r^   )rd   r_   r`   r   r   r   test_imag_npm]   rb   zTestComplex.test_imag_npmc                 C   rQ   rR   )
rD   conjugate_usecaser   r5   rV   r&   rW   rX   r4   rY   rZ   r   r   r   test_conjugate`   r\   zTestComplex.test_conjugatec                 C   r]   r^   )rg   r_   r`   r   r   r   test_conjugate_npmh   rb   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.
        rS   N)	listr!   r"   r)   r   rV   r5   rK   div_usecaser$   r=   rH   rG   r   r   r   test_divk   s
   

zTestComplex.test_divc                 C   r]   r^   )rl   r_   r`   r   r   r   test_div_npmu      zTestComplex.test_div_npmN)rL   rM   rN   rO   r[   ra   rd   re   rg   rh   rl   r   rm   r   r   r   r   rP   H   s    
rP   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e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 Z0dZd[ Z1d\d] Z2d^d_ Z3d`da Z4dbdc Z5dS )e	TestCMathz)
    Tests for cmath module support.
    c                 C   s"   | j |tjtjg|  |d d S r^   )rD   r   rV   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|p|  |||d d S )N)r=   r1   r2   )rD   r   rV   r)   r5   r&   )r$   r:   r=   r1   r2   rH   r   r   r   check_unary_func   s   
zTestCMath.check_unary_funcc                 C      |  tt d S N)rq   phase_usecaserO   r`   r   r   r   
test_phase   rb   zTestCMath.test_phasec                 C   rr   rs   )rq   rt   r_   r`   r   r   r   test_phase_npm   rb   zTestCMath.test_phase_npmc                 C   rr   rs   )rq   polar_usecaserO   r`   r   r   r   
test_polar   rb   zTestCMath.test_polarc                 C   rr   rs   )rq   rw   r_   r`   r   r   r   test_polar_npm   rb   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>rS   )rK   rect_usecase)tpseed_valuesrH   r=   r$   r   r   do_test   s   z$TestCMath.test_rect.<locals>.do_test)r   rY   r)   r4   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   rb   zTestCMath.test_rect_npmc                 C   rr   rs   )rp   isnan_usecaserO   rZ   r   r   r   
test_isnan   rb   zTestCMath.test_isnanc                 C   rr   rs   )rp   r   r_   r`   r   r   r   test_isnan_npm   rb   zTestCMath.test_isnan_npmc                 C   rr   rs   )rp   isinf_usecaserO   rZ   r   r   r   
test_isinf   rb   zTestCMath.test_isinfc                 C   rr   rs   )rp   r   r_   r`   r   r   r   test_isinf_npm   rb   zTestCMath.test_isinf_npmc                 C   rr   rs   )rp   isfinite_usecaserO   rZ   r   r   r   test_isfinite   rb   zTestCMath.test_isfinitec                 C   rr   rs   )rp   r   r_   r`   r   r   r   test_isfinite_npm   rb   zTestCMath.test_isfinite_npmc                 C      | j ttdd d S N   )r1   )rq   exp_usecaserO   r`   r   r   r   test_exp      zTestCMath.test_expc                 C   r   r   )rq   r   r_   r`   r   r   r   test_exp_npm   s   zTestCMath.test_exp_npmc                 C   rr   rs   )rq   log_usecaserO   r`   r   r   r   test_log   rb   zTestCMath.test_logc                 C   rr   rs   )rq   r   r_   r`   r   r   r   test_log_npm   rb   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=   r1   )	ri   r!   r"   r)   r   rV   r5   rK   log_base_usecaserk   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   rn   zTestCMath.test_log_base_npmc                 C   rr   rs   )rq   log10_usecaserO   r`   r   r   r   
test_log10   rb   zTestCMath.test_log10c                 C   rr   rs   )rq   r   r_   r`   r   r   r   test_log10_npm   rb   zTestCMath.test_log10_npmc                 C   rr   rs   )rq   sqrt_usecaserO   r`   r   r   r   	test_sqrt   rb   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>$   )   rS   )rq   r   r_   rangerD   r   rV   )r$   rH   r   r   r   test_sqrt_npm   s
   
zTestCMath.test_sqrt_npmc                 C   r   r   )rq   acos_usecaserO   r`   r   r   r   	test_acos   r   zTestCMath.test_acosc                 C   r   r   )rq   r   r_   r`   r   r   r   test_acos_npm   r   zTestCMath.test_acos_npmc                 C   r   r   )rq   asin_usecaserO   r`   r   r   r   	test_asin   r   zTestCMath.test_asinc                 C   r   r   )rq   r   r_   r`   r   r   r   test_asin_npm   r   zTestCMath.test_asin_npmc                 C   r   r   )rq   atan_usecaserO   r`   r   r   r   	test_atan   r   zTestCMath.test_atanc                 C   r   r   )rq   r   r_   r`   r   r   r   test_atan_npm   r   zTestCMath.test_atan_npmc                 C   r   r   )rq   cos_usecaserO   r`   r   r   r   test_cos   r   zTestCMath.test_cosc                 C   r   r   )rq   r   r_   r`   r   r   r   test_cos_npm   r   zTestCMath.test_cos_npmc                 C   r   Neps)r2   )rq   sin_usecaserO   r`   r   r   r   test_sin  s   zTestCMath.test_sinc                 C   r   r   )rq   r   r_   r`   r   r   r   test_sin_npm  r   zTestCMath.test_sin_npmc                 C   r   r   rq   tan_usecaserO   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   rr   rs   )rq   acosh_usecaserO   r`   r   r   r   
test_acosh  rb   zTestCMath.test_acoshc                 C   rr   rs   )rq   r   r_   r`   r   r   r   test_acosh_npm  rb   zTestCMath.test_acosh_npmc                 C   r   r   )rq   asinh_usecaserO   r`   r   r   r   
test_asinh  r   zTestCMath.test_asinhc                 C   r   r   )rq   r   r_   r`   r   r   r   test_asinh_npm  r   zTestCMath.test_asinh_npmc                 C   r   r   )rq   atanh_usecaserO   r`   r   r   r   
test_atanh  r   zTestCMath.test_atanhc                 C   r   r   )rq   r   r_   r`   r   r   r   test_atanh_npm   r   zTestCMath.test_atanh_npmc                 C   r   r   )rq   cosh_usecaserO   r`   r   r   r   	test_cosh#  r   zTestCMath.test_coshc                 C   r   r   )rq   r   r_   r`   r   r   r   test_cosh_npm&  r   zTestCMath.test_cosh_npmc                 C   r   r   )rq   sinh_usecaserO   r`   r   r   r   	test_sinh)  r   zTestCMath.test_sinhc                 C   r   r   )rq   r   r_   r`   r   r   r   test_sinh_npm,  r   zTestCMath.test_sinh_npmc                 C   r   r   rq   tanh_usecaserO   r`   r   r   r   	test_tanh/  r   zTestCMath.test_tanhc                 C   r   r   r   r`   r   r   r   test_tanh_npm2  r   zTestCMath.test_tanh_npm)r   NN)6rL   rM   rN   __doc__rp   rq   ru   rv   rx   ry   rO   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   r   ro   z   sj    
	

ro   __main__)r!   r'   r   numbar   r   numba.tests.supportr   r   complex_usecasesunittestrO   r_   objectr
   rP   ro   rL   mainr   r   r   r   <module>   s     :2 =