o
    iR                     @   s  d dl Z d dlZ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mZmZ d dlmZmZmZ d dlZd dlmZ e Zde_e Zdd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Z dd Z!dd Z"dd Z#dd Z$d d! Z%d"d# Z&d$d% Z'd&d' Z(d(d) Z)d*d+ Z*d,d- Z+d.d/ Z,d0d1 Z-d2d3 Z.d4d5 Z/d6d7 Z0d8d9 Z1d:d; Z2d<d= Z3d>d? Z4d@dA Z5dBdC Z6dDdE Z7dFdG Z8dHdI Z9dJdK Z:dLdM Z;dNdO Z<dPdQ Z=dRdS Z>dTdU Z?G dVdW dWeZ@eAdXkreB  dS dS )Y    N)compile_isolatedFlags)utilstypes)IS_WIN32	IS_32BITS)TestCaseCompilationCachetag)numpy_supportTc                 C   
   t | S N)mathsinx r   g/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/tests/test_mathlib.pyr         
r   c                 C   r   r   )r   cosr   r   r   r   r      r   r   c                 C   r   r   )r   tanr   r   r   r   r      r   r   c                 C   r   r   )r   sinhr   r   r   r   r   !   r   r   c                 C   r   r   )r   coshr   r   r   r   r   %   r   r   c                 C   r   r   )r   tanhr   r   r   r   r   )   r   r   c                 C   r   r   )r   asinr   r   r   r   r   -   r   r   c                 C   r   r   )r   acosr   r   r   r   r   1   r   r   c                 C   r   r   )r   atanr   r   r   r   r   5   r   r   c                 C      t | |S r   )r   atan2)yr   r   r   r   r   9      r   c                 C   r   r   )r   asinhr   r   r   r   r!   =   r   r!   c                 C   r   r   )r   acoshr   r   r   r   r"   A   r   r"   c                 C   r   r   )r   atanhr   r   r   r   r#   E   r   r#   c                 C   r   r   r   sqrtr   r   r   r   r%   I   r   r%   c                 C   r   r   )npr%   r   r   r   r   npy_sqrtM   r   r'   c                 C   r   r   )r   expr   r   r   r   r(   Q   r   r(   c                 C   r   r   )r   expm1r   r   r   r   r)   U   r   r)   c                 C   r   r   )r   logr   r   r   r   r*   Y   r   r*   c                 C   r   r   )r   log1pr   r   r   r   r+   ]   r   r+   c                 C   r   r   )r   log10r   r   r   r   r,   a   r   r,   c                 C   r   r   )r   floorr   r   r   r   r-   e   r   r-   c                 C   r   r   )r   ceilr   r   r   r   r.   i   r   r.   c                 C   r   r   )r   truncr   r   r   r   r/   m   r   r/   c                 C   r   r   )r   isnanr   r   r   r   r0   q   r   r0   c                 C   r   r   )r   isinfr   r   r   r   r1   u   r   r1   c                 C   r   r   )r   isfiniter   r   r   r   r2   y   r   r2   c                 C   r   r   )r   hypotr   r   r   r   r   r3   }   r    r3   c                 C   r   r   )r   degreesr   r   r   r   r5      r   r5   c                 C   r   r   )r   radiansr   r   r   r   r6      r   r6   c                 C   r   r   )r   erfr   r   r   r   r7      r   r7   c                 C   r   r   )r   erfcr   r   r   r   r8      r   r8   c                 C   r   r   )r   gammar   r   r   r   r9      r   r9   c                 C   r   r   )r   lgammar   r   r   r   r:      r   r:   c                 C   r   r   )r   powr4   r   r   r   r;      r    r;   c                 C   r   r   )r   gcdr4   r   r   r   r<      r    r<   c                 C   r   r   )r   copysignr4   r   r   r   r=      r    r=   c                 C   r   r   )r   frexpr   r   r   r   r>      r   r>   c                 C   r   r   )r   ldexp)r   er   r   r   r?      r    r?   c                   C   s   t jt jfS r   )r   pir@   r   r   r   r   get_constants   r    rB   c                   @   sB  e Zd Zdd Zdd ZedfddZedfdd	Zefd
dZefddZ	dd Z
eejdkd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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d0d1 Zefd2d3Zd4d5 Z efd6d7Z!d8d9 Z"efd:d;Z#d<d= Z$efd>d?Z%d@dA Z&efdBdCZ'dDdE Z(efdFdGZ)dHdI Z*efdJdKZ+dLdM Z,efdNdOZ-dPdQ Z.efdRdSZ/dTdU Z0efdVdWZ1dXdY Z2efdZd[Z3d\d] Z4efd^d_Z5d`da Z6efdbdcZ7ddde Z8efdfdgZ9dhdi Z:djdk Z;dldm Z<dndo Z=dpdq Z>drds Z?dtdu Z@efdvdwZAdxdy ZBefdzd{ZCd|d} ZDefd~dZEdd ZFefddZGdd ZHefddZIdd ZJefddZKdd ZLefddZMdd ZNefddZOefddZPdd ZQdd ZRefddZSdd ZTefddZUdd ZVefddZWdd ZXdS )TestMathLibc                 C   s   t  | _d S r   )r	   ccacheselfr   r   r   setUp   r    zTestMathLib.setUpc                 C   s   |  tt d S r   )Zrun_nullary_funcrB   no_pyobj_flagsrE   r   r   r   test_constants      zTestMathLib.test_constantsexactc                 K   sx   t ||D ]4\}}| jj||f|d}	|	j}
|
|}||}|tju r%dn|}d|f }| j||f||d| qd S )Nflagssinglefor input %rprecmsgziprD   compileentry_pointr   float32assertPreciseEqual)rF   pyfuncx_typesx_valuesrM   rQ   kwargsZtxZvxcrcfuncgotexpectedactual_precrR   r   r   r   	run_unary   s   
zTestMathLib.run_unaryc                 C   s|   t |||D ]5\}}}	| jj|||f|d}
|
j}|||	}|||	}|tju r*dn|}d||	f }| j||||d qd S )NrL   rN   zfor inputs (%r, %r)rP   rS   )rF   rY   rZ   r[   y_valuesrM   rQ   tyr   r   r]   r^   r_   r`   ra   rR   r   r   r   
run_binary   s   

zTestMathLib.run_binaryc                 C   st   t jt jt jt jt jt jt jt jt jt jt jt jg}ddddddt	ddt	dt	ddt	dg}| 
|||| d S )Nr   inf        nan)r   int16int32int64uint16uint32uint64rW   float64floatrb   )rF   rY   rM   rZ   r[   r   r   r   check_predicate_func   s   z TestMathLib.check_predicate_funcc                 C   D   t }tjtjtjtjtjtjtjtj	g}g d}| 
|||| d S Nru         rw   皙?皙?)r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   rF   rM   rY   rZ   r[   r   r   r   test_sin      zTestMathLib.test_sinc                 C      | j td d S NrL   )r|   rH   rE   r   r   r   test_sin_npm   rJ   zTestMathLib.test_sin_npmwin32z'not exactly equal on win32 (issue #597)c                 C   rr   rs   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   test_cos   s   zTestMathLib.test_cosc                 C   r~   r   )r   rH   rE   r   r   r   test_cos_npm   rJ   zTestMathLib.test_cos_npmc                 C   rr   rs   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   test_tan   r}   zTestMathLib.test_tanc                 C   r~   r   )r   rH   rE   r   r   r   test_tan_npm   rJ   zTestMathLib.test_tan_npmc                 C   rr   )Nrw   rx   rw   rw   rx   rw   ry   rz   )r%   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_sqrt   r}   zTestMathLib.test_sqrtc                 C   r~   r   )r   rH   rE   r   r   r   test_sqrt_npm  rJ   zTestMathLib.test_sqrt_npmc                 C   s\   t }g d}tjtjg}| j||||dd tjtjtjtjtj	tj
g}| |||| d S )Nr   rN   rQ   )r'   r   ri   rl   rb   rj   rk   rm   rn   rW   ro   rF   rM   rY   r[   rZ   r   r   r   test_npy_sqrt  s   zTestMathLib.test_npy_sqrtc                 C   r~   r   )r   rH   rE   r   r   r   test_npy_sqrt_npm  rJ   zTestMathLib.test_npy_sqrt_npmc                 C   rr   rs   )r(   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   test_exp  r}   zTestMathLib.test_expc                 C   r~   r   )r   rH   rE   r   r   r   test_exp_npm  rJ   zTestMathLib.test_exp_npmc                 C   rr   rs   )r)   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_expm1  r}   zTestMathLib.test_expm1c                 C   r~   r   )r   rH   rE   r   r   r   test_expm1_npm'  rJ   zTestMathLib.test_expm1_npmc                 C   rr   N)rx   
   d   i  i i@B ry   g?)r*   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   test_log*  r}   zTestMathLib.test_logc                 C   r~   r   )r   rH   rE   r   r   r   test_log_npm2  rJ   zTestMathLib.test_log_npmc                 C   rr   r   )r+   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_log1p5  r}   zTestMathLib.test_log1pc                 C   r~   r   )r   rH   rE   r   r   r   test_log1p_npm=  rJ   zTestMathLib.test_log1p_npmc                 C   rr   r   )r,   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_log10@  r}   zTestMathLib.test_log10c                 C   r~   r   )r   rH   rE   r   r   r   test_log10_npmH  rJ   zTestMathLib.test_log10_npmc                 C   rr   Nrx   rx   rx   rx   rx   rx         ?r   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_asinK  r}   zTestMathLib.test_asinc                 C   r~   r   )r   rH   rE   r   r   r   test_asin_npmS  rJ   zTestMathLib.test_asin_npmc                 C   rr   r   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_acosV  r}   zTestMathLib.test_acosc                 C   r~   r   )r   rH   rE   r   r   r   test_acos_npm^  rJ   zTestMathLib.test_acos_npmc                 C   rr   rs   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_atana  r}   zTestMathLib.test_atanc                 C   r~   r   )r   rH   rE   r   r   r   test_atan_npmi  rJ   zTestMathLib.test_atan_npmc                 C   T   t }tjtjtjtjtjtjtjtj	g}g d}dd |D }| 
||||| d S )Nrt   c                 S      g | ]}|d  qS rw   r   .0r   r   r   r   
<listcomp>r      z*TestMathLib.test_atan2.<locals>.<listcomp>)r   r   ri   rj   rk   rl   rm   rn   rW   ro   re   rF   rM   rY   rZ   r[   rc   r   r   r   
test_atan2l     zTestMathLib.test_atan2c                 C   r~   r   )r   rH   rE   r   r   r   test_atan2_npmu  rJ   zTestMathLib.test_atan2_npmc                 C   H   t }tjtjtjtjtjtjtjtj	g}g d}| j
||||dd d S )Nr   doubler   )r!   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_asinhx     zTestMathLib.test_asinhc                 C   r~   r   )r   rH   rE   r   r   r   test_asinh_npm  rJ   zTestMathLib.test_asinh_npmc                 C   rr   r   )r"   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_acosh  r}   zTestMathLib.test_acoshc                 C   r~   r   )r   rH   rE   r   r   r   test_acosh_npm  rJ   zTestMathLib.test_acosh_npmc                 C   r   )Nr   r   r   r   r   r   ry   ry   r   r   )r#   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_atanh  r   zTestMathLib.test_atanhc                 C   r~   r   )r   rH   rE   r   r   r   test_atanh_npm  rJ   zTestMathLib.test_atanh_npmc                 C   rr   r   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_sinh  r}   zTestMathLib.test_sinhc                 C   r~   r   )r   rH   rE   r   r   r   test_sinh_npm  rJ   zTestMathLib.test_sinh_npmc                 C   rr   r   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_cosh  r}   zTestMathLib.test_coshc                 C   r~   r   )r   rH   rE   r   r   r   test_cosh_npm  rJ   zTestMathLib.test_cosh_npmc                 C   rr   )Nr   )r   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_tanh  r}   zTestMathLib.test_tanhc                 C   r~   r   )r   rH   rE   r   r   r   test_tanh_npm  rJ   zTestMathLib.test_tanh_npmc                 C   rr   N)r   r   r   r   r   r   ry   gffffff?)r-   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_floor  r}   zTestMathLib.test_floorc                 C   r~   r   )r   rH   rE   r   r   r   test_floor_npm  rJ   zTestMathLib.test_floor_npmc                 C   rr   r   )r.   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   	test_ceil  r}   zTestMathLib.test_ceilc                 C   r~   r   )r   rH   rE   r   r   r   test_ceil_npm  rJ   zTestMathLib.test_ceil_npmc                 C   rr   r   )r/   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   
test_trunc  r}   zTestMathLib.test_truncc                 C   r~   r   )r   rH   rE   r   r   r   test_trunc_npm  rJ   zTestMathLib.test_trunc_npmc                 C      | j ttd d S r   )rq   r0   enable_pyobj_flagsrE   r   r   r   
test_isnan     zTestMathLib.test_isnanc                 C   r   r   )rq   r0   rH   rE   r   r   r   test_isnan_npm  r   zTestMathLib.test_isnan_npmc                 C   r   r   )rq   r1   r   rE   r   r   r   
test_isinf  r   zTestMathLib.test_isinfc                 C   r   r   )rq   r1   rH   rE   r   r   r   test_isinf_npm  r   zTestMathLib.test_isinf_npmc                 C   r   r   )rq   r2   r   rE   r   r   r   test_isfinite  r   zTestMathLib.test_isfinitec                 C   r   r   )rq   r2   rH   rE   r   r   r   test_isfinite_npm  r   zTestMathLib.test_isfinite_npmc              	   C   s  t }tjtjtjtjg}g d}dd |D }d}| |||||| dd }tjtjfD ][}| jj|||f|d}	|	j	}
t
|j}|t|jd }|
||}| j||||dd	 | t| t  td
t | td||| W d    n1 sw   Y  q-d S )N)rx   rw               gzG?g(\?c                 S   s   g | ]}|d  qS r   r   r   r   r   r   r     r   z*TestMathLib.test_hypot.<locals>.<listcomp>rN   c                 S   s   t | |  ||  S r   r$   r4   r   r   r   naive_hypot  s   z+TestMathLib.test_hypot.<locals>.naive_hypotrL   g      >@r   errorz overflow encountered in .*scalar)r3   r   rk   rn   rW   ro   re   rD   rU   rV   r   Zas_dtypetyper&   ZfinfomaxrX   
assertTruer2   warningscatch_warningssimplefilterRuntimeWarningZassertRaisesRegexp)rF   rM   rY   rZ   r[   rc   rQ   r   flttyr]   r^   dtvalZnb_ansr   r   r   
test_hypot  s4   

zTestMathLib.test_hypotc                 C   r~   r   )r   rH   rE   r   r   r   test_hypot_npm
  rJ   zTestMathLib.test_hypot_npmc                 C   rr   r   )r5   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   test_degrees  r}   zTestMathLib.test_degreesc                 C   r~   r   )r   rH   rE   r   r   r   test_degrees_npm  rJ   zTestMathLib.test_degrees_npmc                 C   rr   r   )r6   r   ri   rj   rk   rl   rm   rn   rW   ro   rb   r{   r   r   r   test_radians  r}   zTestMathLib.test_radiansc                 C   r~   r   )r   rH   rE   r   r   r   test_radians_npm   rJ   zTestMathLib.test_radians_npmc              	   C   sN   t }dddddddtdg}tjtjgt|d  }| j||||d	dd
 d S )Nr                rg         ?r   rf   rw   r   rQ   Zulps)r7   rp   r   rW   ro   lenrb   r   r   r   r   test_erf#     
zTestMathLib.test_erfc                 C   r~   r   )r   rH   rE   r   r   r   test_erf_npm*  rJ   zTestMathLib.test_erf_npmc              	   C   sN   t }dddddddtdg}tjtjgt|d  }| j||||d	d
d d S )Nr   r   r   rg   r   r   rf   rw   r   r   r   )r8   rp   r   rW   ro   r   rb   r   r   r   r   	test_erfc-  r   zTestMathLib.test_erfcc                 C   r~   r   )r   rH   rE   r   r   r   test_erfc_npm4  rJ   zTestMathLib.test_erfc_npmc                 C   sx   t }g d}tjtjgt|d  }| j||||ddd dddd	d
tdg}tjgt| }| j||||ddd d S )N)r   g      r   rw   r   r   r   皙ry         @g333333$@g      I@rf      )r9   r   rW   ro   r   rb   rp   r   r   r   r   
test_gamma7  s   
zTestMathLib.test_gammac                 C   r~   r   )r   rH   rE   r   r   r   test_gamma_npmA  rJ   zTestMathLib.test_gamma_npmc              	   C   sL   t }dddddddtdg}tjtjgt|d	  }| j||||d
d d S )Nr   r   r   ry   g      i@g    _Bgꌠ9Y>)Frf   rw   r   r   )r:   rp   r   rW   ro   r   rb   r   r   r   r   test_lgammaD  s   zTestMathLib.test_lgammac                 C   r~   r   )r   rH   rE   r   r   r   test_lgamma_npmJ  rJ   zTestMathLib.test_lgamma_npmc                 C   r   )Nrt   c                 S   r   r   r   r   r   r   r   r   S  r   z(TestMathLib.test_pow.<locals>.<listcomp>)r;   r   ri   rj   rk   rl   rm   rn   rW   ro   re   r   r   r   r   test_powM  r   zTestMathLib.test_powc                 C   sz   ddl m}m}m} t}|ttjg|ddR  }|ttjg|ddR  }t	||| \}}	}
| 
|||	|
| d S )Nr   )productrepeatchain)ru   rv   r   rx   rw      r   rw   )r   rx   rw   r   	      )	itertoolsr   r   r   r<   sortedr   Zsigned_domainZunsigned_domainrT   re   )rF   rM   r   r   r   rY   Zsigned_argsZunsigned_argsrZ   r[   rc   r   r   r   test_gcdV  s   zTestMathLib.test_gcdc                 C   r~   r   )r   rH   rE   r   r   r   test_gcd_npmb  rJ   zTestMathLib.test_gcd_npmc                 C   r~   r   )r   rH   rE   r   r   r   test_pow_npme  rJ   zTestMathLib.test_pow_npmc              
   C   sd   t }tjtjg}ddddddtdtdtd	g	}ttt||| \}}}| 	||||| d S )
Nru   rv   r   rg   rx   rw   -infrf   rh   )
r=   r   rW   ro   rp   listrT   r   r   re   )rF   rM   rY   Zvalue_typesvaluesrZ   r[   rc   r   r   r   test_copysignh  s   zTestMathLib.test_copysignc                 C   r~   r   )r  rH   rE   r   r   r   test_copysign_npmq  rJ   zTestMathLib.test_copysign_npmc                 C   sF   t }tjtjg}ddddtdtdtdg}| j||||dd	 d S )
Ng      r   rg   g      @r  rf   rh   rK   r   )r>   r   rW   ro   rp   rb   r{   r   r   r   
test_frexpt  s   zTestMathLib.test_frexpc                 C   r~   r   )r  rH   rE   r   r   r   test_frexp_npm{  rJ   zTestMathLib.test_frexp_npmc                 C   s   t }tjtjfD ]:}| jj||tjf|d}|j}ddddddtdd	ftd
d	ftdd	ff	D ]}d|f }| 	|| ||  q0qd S )NrL   )r   ru   )r   rx   )rg   r   )rg   rx   )r   r   )r   rx   rf   r   r  rh   rO   )
r?   r   rW   ro   rD   rU   rj   rV   rp   rX   )rF   rM   rY   r   r]   r^   argsrR   r   r   r   
test_ldexp~  s   

zTestMathLib.test_ldexpc                 C   r~   r   )r
  rH   rE   r   r   r   test_ldexp_npm  rJ   zTestMathLib.test_ldexp_npmN)Y__name__
__module____qualname__rG   rI   r   rb   re   rq   r|   r   unittestZskipIfsysplatformr   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   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      s    


	
		rC   __main__)Cr   r   r  r   numpyr&   Znumba.core.compilerr   r   Z
numba.corer   r   Znumba.core.configr   r   Znumba.tests.supportr   r	   r
   r  Znumba.npr   r   Zenable_pyobjectrH   r   r   r   r   r   r   r   r   r   r   r!   r"   r#   r%   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   rB   rC   r  mainr   r   r   r   <module>   sx       b