
    xKgD                        d dl Z 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 d dlmZ d Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d  Z)d! Z*d" Z+d# Z,d$ Z-d% Z.d& Z/d' Z0d( Z1d) Z2d* Z3d+ Z4d, Z5d- Z6 G d. d/e      Z7e8d0k(  r ejr                          yy)1    N)njittypes)TestCase)numpy_supportc                 ,    t        j                  |       S N)mathsinxs    \/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_mathlib.pyr
   r
          88A;    c                 ,    t        j                  |       S r   )r	   cosr   s    r   r   r      r   r   c                 ,    t        j                  |       S r   )r	   tanr   s    r   r   r      r   r   c                 ,    t        j                  |       S r   )r	   sinhr   s    r   r   r          99Q<r   c                 ,    t        j                  |       S r   )r	   coshr   s    r   r   r      r   r   c                 ,    t        j                  |       S r   )r	   tanhr   s    r   r   r   "   r   r   c                 ,    t        j                  |       S r   )r	   asinr   s    r   r   r   &   r   r   c                 ,    t        j                  |       S r   )r	   acosr   s    r   r   r   *   r   r   c                 ,    t        j                  |       S r   )r	   atanr   s    r   r    r    .   r   r   c                 .    t        j                  | |      S r   )r	   atan2)yr   s     r   r"   r"   2       ::ar   c                 ,    t        j                  |       S r   )r	   asinhr   s    r   r&   r&   6       ::a=r   c                 ,    t        j                  |       S r   )r	   acoshr   s    r   r)   r)   :   r'   r   c                 ,    t        j                  |       S r   )r	   atanhr   s    r   r+   r+   >   r'   r   c                 ,    t        j                  |       S r   r	   sqrtr   s    r   r.   r.   B   r   r   c                 ,    t        j                  |       S r   )npr.   r   s    r   npy_sqrtr1   F   s    771:r   c                 ,    t        j                  |       S r   )r	   expr   s    r   r3   r3   J   r   r   c                 ,    t        j                  |       S r   )r	   expm1r   s    r   r5   r5   N   r'   r   c                 ,    t        j                  |       S r   )r	   logr   s    r   r7   r7   R   r   r   c                 ,    t        j                  |       S r   )r	   log1pr   s    r   r9   r9   V   r'   r   c                 ,    t        j                  |       S r   )r	   log10r   s    r   r;   r;   Z   r'   r   c                 ,    t        j                  |       S r   )r	   log2r   s    r   r=   r=   ^   r   r   c                 ,    t        j                  |       S r   )r	   floorr   s    r   r?   r?   b   r'   r   c                 ,    t        j                  |       S r   )r	   ceilr   s    r   rA   rA   f   r   r   c                 ,    t        j                  |       S r   )r	   truncr   s    r   rC   rC   j   r'   r   c                 ,    t        j                  |       S r   )r	   isnanr   s    r   rE   rE   n   r'   r   c                 ,    t        j                  |       S r   )r	   isinfr   s    r   rG   rG   r   r'   r   c                 ,    t        j                  |       S r   )r	   isfiniter   s    r   rI   rI   v   s    ==r   c                 .    t        j                  | |      S r   )r	   hypotr   r#   s     r   rK   rK   z   r$   r   c                 .    t        j                  | |      S r   )r	   	nextafterrL   s     r   rN   rN   ~   s    >>!Qr   c                 ,    t        j                  |       S r   )r	   degreesr   s    r   rP   rP          <<?r   c                 ,    t        j                  |       S r   )r	   radiansr   s    r   rS   rS      rQ   r   c                 ,    t        j                  |       S r   )r	   erfr   s    r   rU   rU      r   r   c                 ,    t        j                  |       S r   )r	   erfcr   s    r   rW   rW      r   r   c                 ,    t        j                  |       S r   )r	   gammar   s    r   rY   rY      r'   r   c                 ,    t        j                  |       S r   )r	   lgammar   s    r   r[   r[      s    ;;q>r   c                 .    t        j                  | |      S r   )r	   powrL   s     r   r]   r]          88Aq>r   c                 .    t        j                  | |      S r   )r	   gcdrL   s     r   r`   r`      r^   r   c                 .    t        j                  | |      S r   )r	   copysignrL   s     r   rb   rb      s    ==Ar   c                 ,    t        j                  |       S r   )r	   frexpr   s    r   rd   rd      r'   r   c                 .    t        j                  | |      S r   )r	   ldexp)r   es     r   rf   rf      r$   r   c                  B    t         j                  t         j                  fS r   )r	   pirg    r   r   get_constantsrk      s    77DFF?r   c                   ^   e Zd Zd Zd0dZd0dZd Zd Z ej                  e
j                  dk(  d      d        Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d  Z$d! Z%d" Z&d# Z'd$ Z(d% Z)d& Z*d' Z+d( Z,d) Z-d* Z.d+ Z/d, Z0d- Z1d. Z2y/)1TestMathLibc                 l    t        t              }| j                   |       |j                                y r   )r   rk   assertPreciseEqualpy_func)selfcfuncs     r   test_constantszTestMathLib.test_constants   s$    ]#9r   c                     t        |      }t        ||      D ]G  \  }} ||      }	 ||      }
|t        j                  u rdn|}d|} | j                  |	|
f||d| I y )Nsingle
for input precmsgr   zipr   float32ro   )rq   pyfuncx_typesx_valuesrx   kwargsrr   txvxgotexpectedactual_precry   s                r   	run_unaryzTestMathLib.run_unary   sq    V'8,FB)CbzH&(EMM&9(tK$&(C#D##C . .&,. -r   c                     t        |      }t        |||      D ]L  \  }}}	 |||	      }
 |||	      }|t        j                  u rdn|}d|d|	d}| j	                  |
|||       N y )Nru   zfor inputs (z, )rw   rz   )rq   r}   r~   r   y_valuesrx   rr   tyr   r#   r   r   r   ry   s                 r   
run_binaryzTestMathLib.run_binary   sm    VGXx8HB11+Ca|H&(EMM&9(tK+,a0C##C#M 9r   c                    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}| j                  |||       y )Nr   inf        nan)r   int16int32int64uint16uint32uint64r|   float64floatr   rq   r}   r~   r   s       r   check_predicate_funcz TestMathLib.check_predicate_func   s    ;;U[[<<u||==%--==%--@ q!Q1%L#uU|%L#uU|5 	vw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y Nr         r   皙?皙?)r
   r   r   r   r   r   r   r   r|   r   r   r   s       r   test_sinzTestMathLib.test_sin   X    ;;U[[<<u||==%--1 1vw1r   win32z'not exactly equal on win32 (issue #597)c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r   r   r   r   r   r   r   r   r|   r   r   r   s       r   test_coszTestMathLib.test_cos   sZ     ;;U[[<<u||==%--1 1vw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r   r   r   r   r   r   r   r   r|   r   r   r   s       r   test_tanzTestMathLib.test_tan   r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y )Nr   r   r   r   r   r   r   r   )r.   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_sqrtzTestMathLib.test_sqrt   X    ;;U[[<<u||==%--1 .vw1r   c                 `   t         }g d}t        j                  t        j                  g}| j	                  |||d       t        j
                  t        j                  t        j                  t        j                  t        j                  t        j                  g}| j	                  |||       y )Nr   ru   rx   )r1   r   r   r   r   r   r   r   r   r|   r   rq   r}   r   r~   s       r   test_npy_sqrtzTestMathLib.test_npy_sqrt   sr    -;;-vwx@;;<<==%--1 	vw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r3   r   r   r   r   r   r   r   r|   r   r   r   s       r   test_expzTestMathLib.test_exp   r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r5   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_expm1zTestMathLib.test_expm1  sX    ;;U[[<<u||==%--1 1vw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y N)r   
   d   i  i i@B r   g?)r7   r   r   r   r   r   r   r   r|   r   r   r   s       r   test_logzTestMathLib.test_log  sY    ;;U[[<<u||==%--1 Avw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r9   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_log1pzTestMathLib.test_log1p  Y    ;;U[[<<u||==%--1 Avw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r;   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_log10zTestMathLib.test_log10   r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r=   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_log2zTestMathLib.test_log2(  sY    ;;U[[<<u||==%--1 Avw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y Nr   r   r   r   r   r         ?r   )r   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_asinzTestMathLib.test_asin0  r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_acoszTestMathLib.test_acos8  r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r    r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_atanzTestMathLib.test_atan@  sX    ;;U[[<<u||==%--1 1vw1r   c                 b   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}|D cg c]  }|dz  	 }}| j                  ||||       y c c}w Nr   r   )r"   r   r   r   r   r   r   r   r|   r   r   rq   r}   r~   r   r   r   s         r   
test_atan2zTestMathLib.test_atan2H  sw    ;;U[[<<u||==%--1 1#+,8aAE8,8< -   	B,c                 6   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||d       y )Nr   doubler   )r&   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_asinhzTestMathLib.test_asinhQ  s\    ;;U[[<<u||==%--1 .vwx@r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r)   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_acoshzTestMathLib.test_acoshY  sX    ;;U[[<<u||==%--1 .vw1r   c                 6   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||d       y )Nr   r   r   r   r   r   r   r   r   r   )r+   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_atanhzTestMathLib.test_atanha  s\    ;;U[[<<u||==%--1 0vwx@r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_sinhzTestMathLib.test_sinhi  r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )r   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_coshzTestMathLib.test_coshq  r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y )Nr   )r   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_tanhzTestMathLib.test_tanhy  X    ;;U[[<<u||==%--1 0vw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y N)r   r   r   r   r   r   r   gffffff?)r?   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_floorzTestMathLib.test_floor  X    ;;U[[<<u||==%--1 0vw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )rA   r   r   r   r   r   r   r   r|   r   r   r   s       r   	test_ceilzTestMathLib.test_ceil  r   r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )rC   r   r   r   r   r   r   r   r|   r   r   r   s       r   
test_trunczTestMathLib.test_trunc  r   r   c                 .    | j                  t               y r   )r   rE   rq   s    r   
test_isnanzTestMathLib.test_isnan      !!%(r   c                 .    | j                  t               y r   )r   rG   r   s    r   
test_isinfzTestMathLib.test_isinf  r   r   c                 .    | j                  t               y r   )r   rI   r   s    r   test_isfinitezTestMathLib.test_isfinite  s    !!(+r   c           	      ,   t         }t        j                  t        j                  t        j                  t        j
                  g}g d}|D cg c]  }|dz   	 }}d}| j                  |||||       d }t        |      }t        j                  t        j
                  fD ]  }	t        j                  |	      j                  }
 |
t        j                  |
      j                  dz        } |||      }| j                  | |||      d       | j                  t        j                   |             t#        j$                         5  t#        j&                  dt(               | j+                  t(        d|||       d d d         y c c}w # 1 sw Y   xY w)	N)r   r               zG?(\?r   ru   c                 >    t        j                  | | z  ||z  z         S r   r-   rL   s     r   naive_hypotz+TestMathLib.test_hypot.<locals>.naive_hypot  s    99QUQU]++r   g      >@r   errorz overflow encountered in .*scalar)rK   r   r   r   r|   r   r   r   r   as_dtypetyper0   finfomaxro   
assertTruerI   warningscatch_warningssimplefilterRuntimeWarningassertRaisesRegex)rq   r}   r~   r   r   r   rx   r   rr   flttydtvalnb_anss                r   
test_hypotzTestMathLib.test_hypot  s@   ;;==%--1/#+,8aAE8,8TB	, VmmU]]3E''.33BRXXb\%%+,C3_F##FF3,<8#LOOBKK/0((*%%g~>&&~(J(3S#? +* 4 -$ +*s   F4F

F	c                 F   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  g}g d}|D cg c]  }|dz   	 }}|D cg c]  }|dz
  	 }}| j                  ||||       | j                  ||||       | j                  ||g dt        j                  gdz         | j                  ||g dt        j                   gdz         | j                  ||||       y c c}w c c}w )N)r   r   r   g%.AgS9r   )r               ?r   )rN   r   r|   r   r   r   r   r   r   r	   r   )rq   r}   r~   r   r   	y1_values	y2_valuess          r   test_nextafterzTestMathLib.test_nextafter  s    ==%--;;<</ 9$,-HqQUH	-$,-HqQUH	-9=9= 	$((AF488)QG 	8< .-s   +D=Dc                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )rP   r   r   r   r   r   r   r   r|   r   r   r   s       r   test_degreeszTestMathLib.test_degrees  X    ;;U[[<<u||==%--1 .vw1r   c                 2   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}| j                  |||       y r   )rS   r   r   r   r   r   r   r   r|   r   r   r   s       r   test_radianszTestMathLib.test_radians  r  r   c           
          t         }dddddddt        d      g}t        j                  t        j                  gt        |      dz  z  }| j                  |||d	d
       y )Nr                r   r
  r   r   r   r   rx   ulps)rU   r   r   r|   r   lenr   r   s       r   test_erfzTestMathLib.test_erf  sW    CsCE%LA==%--0CMQ4FGvwxaHr   c           
          t         }dddddddt        d      g}t        j                  t        j                  gt        |      dz  z  }| j                  |||d	d
       y )Nr   r  r  r   r
  r   r   r   r   r   r  )rW   r   r   r|   r   r  r   r   s       r   	test_erfczTestMathLib.test_erfc  sW    CsCE%LA==%--0CMQ4FGvwxaHr   c                 *   t         }g d}t        j                  t        j                  gt	        |      dz  z  }| j                  |||dd       dddd	d
t        d      g}t        j                  gt	        |      z  }| j                  |||dd       y )N)r   r	  r
  r   r   r   r  皙r         @g333333$@g      I@r      )rY   r   r|   r   r  r   r   r   s       r   
test_gammazTestMathLib.test_gamma  s    (==%--0CMQ4FGvwxaH#sD#uU|<==/CM1vwxaHr   c           
          t         }dddddddt        d      g}t        j                  t        j                  gt        |      d	z  z  }| j                  |||d
       y )Nr   r  r  r   g      i@g    _Bgꌠ9Y>)Fr   r   r   r   )r[   r   r   r|   r   r  r   r   s       r   test_lgammazTestMathLib.test_lgamma  sU    dCtT5<H==%--0CMQ4FGvwx@r   c                 b   t         }t        j                  t        j                  t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  g}g d}|D cg c]  }|dz  	 }}| j                  ||||       y c c}w r   )r]   r   r   r   r   r   r   r   r|   r   r   r   s         r   test_powzTestMathLib.test_pow  sw    ;;U[[<<u||==%--1 1#+,8aAE8,8< -r   c                    ddl m}m}m} t        } |t        t        j                        g |dd       } |t        t        j                        g |dd       }t         |||       \  }}}	| j                  ||||	       y )Nr   )productrepeatchain)r   r   r   r   r      r   r   )r   r   r   r*  	      )	itertoolsr'  r(  r)  r`   sortedr   signed_domainunsigned_domainr{   r   )
rq   r'  r(  r)  r}   signed_argsunsigned_argsr~   r   r   s
             r   test_gcdzTestMathLib.test_gcd  s    445&&'
*01I1*M
  5(()
,23F,J
 '*5m+L&M#88<r   c                    t         }t        j                  t        j                  g}ddddddt	        d      t	        d      t	        d	      g	}t        t        t        j                  |||             \  }}}| j                  ||||       y )
Nr   r   r  r   r   r   -infr   r   )
rb   r   r|   r   r   listr{   r-  r'  r   )rq   r}   value_typesvaluesr~   r   r   s          r   test_copysignzTestMathLib.test_copysign  s|    }}emm4b$Q5=%,, &*3{FF;,= '>#88<r   c           	          t         }t        j                  t        j                  g}ddddt	        d      t	        d      t	        d      g}| j                  |||d	       y )
Ng      r  r   g      @r5  r   r   exactr   )rd   r   r|   r   r   r   r   s       r   
test_frexpzTestMathLib.test_frexp  sP    ==%--0$S&M5<u?vww?r   c                    t         }t        |      }t        j                  t        j                  fD ]P  }ddddddt        d      dft        d	      dft        d
      dff	D ]  }d|}| j                   ||  ||        ! R y )N)r  r   )r  r   )r   r   )r   r   )r  r   )r  r   r   r   r5  r   rv   )rf   r   r   r|   r   r   ro   )rq   r}   rr   r  argsry   s         r   
test_ldexpzTestMathLib.test_ldexp"  s    VmmU]]3E"Hh"I,*U6]A,>,*, )-.''tfdmD, 4r   N)r;  )3__name__
__module____qualname__rs   r   r   r   r   unittest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%  r3  r9  r<  r?  rj   r   r   rm   rm      s   :.N22 X__S\\W,>@2@222	2222222222=A2A222222)),?:=&22IIIA=
==@	Er   rm   __main__):r-  r	   rE  rC  r   numpyr0   numbar   r   numba.tests.supportr   numba.npr   r
   r   r   r   r   r   r   r   r    r"   r&   r)   r+   r.   r1   r3   r5   r7   r9   r;   r=   r?   rA   rC   rE   rG   rI   rK   rN   rP   rS   rU   rW   rY   r[   r]   r`   rb   rd   rf   rk   rm   r@  mainrj   r   r   <module>rM     s     
     ( " {E( {E| zHMMO r   