
    wiE                        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 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& Z0d' Z1d( Z2d) Z3d* Z4d+ Z5d, Z6d- Z7d. Z8d/ Z9 G d0 d1e          Z:e;d2k    r ej<                     dS dS )3    N)njittypes)TestCase)numpy_support)	PYVERSIONc                 *    t          j        |           S N)mathsinxs    h/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/numba/tests/test_mathlib.pyr   r          8A;;    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          9Q<<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#   3       :ar   c                 *    t          j        |           S r	   )r
   asinhr   s    r   r'   r'   7       :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/   C   r   r   c                 *    t          j        |           S r	   )npr/   r   s    r   npy_sqrtr2   G   s    71::r   c                 *    t          j        |           S r	   )r
   expr   s    r   r4   r4   K   r   r   c                 *    t          j        |           S r	   )r
   exp2r   s    r   r6   r6   N   r   r   c                 *    t          j        |           S r	   )r
   expm1r   s    r   r8   r8   Q   r(   r   c                 *    t          j        |           S r	   )r
   logr   s    r   r:   r:   U   r   r   c                 *    t          j        |           S r	   )r
   log1pr   s    r   r<   r<   Y   r(   r   c                 *    t          j        |           S r	   )r
   log10r   s    r   r>   r>   ]   r(   r   c                 *    t          j        |           S r	   )r
   log2r   s    r   r@   r@   a   r   r   c                 *    t          j        |           S r	   )r
   floorr   s    r   rB   rB   e   r(   r   c                 *    t          j        |           S r	   )r
   ceilr   s    r   rD   rD   i   r   r   c                 *    t          j        |           S r	   )r
   truncr   s    r   rF   rF   m   r(   r   c                 *    t          j        |           S r	   )r
   isnanr   s    r   rH   rH   q   r(   r   c                 *    t          j        |           S r	   )r
   isinfr   s    r   rJ   rJ   u   r(   r   c                 *    t          j        |           S r	   )r
   isfiniter   s    r   rL   rL   y   s    =r   c                 ,    t          j        | |          S r	   )r
   hypotr   r$   s     r   rN   rN   }   r%   r   c                 ,    t          j        | |          S r	   )r
   	nextafterrO   s     r   rQ   rQ      s    >!Qr   c                 *    t          j        |           S r	   )r
   degreesr   s    r   rS   rS          <??r   c                 *    t          j        |           S r	   )r
   radiansr   s    r   rV   rV      rT   r   c                 *    t          j        |           S r	   )r
   erfr   s    r   rX   rX      r   r   c                 *    t          j        |           S r	   )r
   erfcr   s    r   rZ   rZ      r   r   c                 *    t          j        |           S r	   )r
   gammar   s    r   r\   r\      r(   r   c                 *    t          j        |           S r	   )r
   lgammar   s    r   r^   r^      s    ;q>>r   c                 ,    t          j        | |          S r	   )r
   powrO   s     r   r`   r`          8Aq>>r   c                 ,    t          j        | |          S r	   )r
   gcdrO   s     r   rc   rc      ra   r   c                 ,    t          j        | |          S r	   )r
   copysignrO   s     r   re   re      s    =Ar   c                 *    t          j        |           S r	   )r
   frexpr   s    r   rg   rg      r(   r   c                 ,    t          j        | |          S r	   )r
   ldexp)r   es     r   ri   ri      r%   r   c                  2    t           j        t           j        fS r	   )r
   pirj    r   r   get_constantsrn      s    7DF?r   c                      e Zd Zd Zd4dZd4dZd Zd Z ej	        e
j        dk    d          d	             Zd
 Zd Zd Zd Z ej        e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- Z0d. Z1d/ Z2d0 Z3d1 Z4d2 Z5d3S )5TestMathLibc                     t          t                    }|                      |            |                                           d S r	   )r   rn   assertPreciseEqualpy_func)selfcfuncs     r   test_constantszTestMathLib.test_constants   s9    ]##99999r   exactc                     t          |          }t          ||          D ]D\  }} ||          }	 ||          }
|t          j        u rdn|}d|} | j        |	|
f||d| Ed S )Nsingle
for input precmsgr   zipr   float32rr   )rt   pyfuncx_typesx_valuesr|   kwargsru   txvxgotexpectedactual_precr}   s                r   	run_unaryzTestMathLib.run_unary   s    V'8,, 	. 	.FB%))CvbzzH&(EM&9&9((tKK$&B(C#D#C . . .&,. . . .	. 	.r   c                     t          |          }t          |||          D ]R\  }}}	 |||	          }
 |||	          }|t          j        u rdn|}d|d|	d}|                     |
|||           Sd S )Nry   zfor inputs (z, )r{   r~   )rt   r   r   r   y_valuesr|   ru   tyr   r$   r   r   r   r}   s                 r   
run_binaryzTestMathLib.run_binary   s    VGXx88 	N 	NHB1%1++Cva||H&(EM&9&9((tKK+,11aaa0C##C#MMMM	N 	Nr   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}| 
                    |||           d S )Nr   inf        nan)r   int16int32int64uint16uint32uint64r   float64floatr   rt   r   r   r   s       r   check_predicate_funcz TestMathLib.check_predicate_func   s    ;U[<u|=%-=%-@ q!Q1%LL#uU||%LL#uU||5 	vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S Nr         r   皙?皙?)r   r   r   r   r   r   r   r   r   r   r   r   s       r   test_sinzTestMathLib.test_sin   Z    ;U[<u|=%-1 100vw11111r   win32z'not exactly equal on win32 (issue #597)c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r   r   r   r   r   r   r   r   r   r   r   r   s       r   test_coszTestMathLib.test_cos   s\     ;U[<u|=%-1 100vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r   r   r   r   r   r   r   r   r   r   r   r   s       r   test_tanzTestMathLib.test_tan   r   r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S )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   Z    ;U[<u|=%-1 .--vw11111r   c                 4   t           }g d}t          j        t          j        g}|                     |||d           t          j        t          j        t          j        t          j        t          j	        t          j
        g}|                     |||           d S )Nr   ry   r|   )r2   r   r   r   r   r   r   r   r   r   r   rt   r   r   r   s       r   test_npy_sqrtzTestMathLib.test_npy_sqrt   sz    ---;-vwx@@@;<=%-1 	vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r4   r   r   r   r   r   r   r   r   r   r   r   s       r   test_expzTestMathLib.test_exp  r   r   )      zneeds Python 3.11+c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r6   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_exp2zTestMathLib.test_exp2  sZ    ;U[<u|=%-1 100vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r8   r   r   r   r   r   r   r   r   r   r   r   s       r   
test_expm1zTestMathLib.test_expm1  sZ    ;U[<u|=%-1 100vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S N)r   
   d   i  i i@B r   g?)r:   r   r   r   r   r   r   r   r   r   r   r   s       r   test_logzTestMathLib.test_log  s[    ;U[<u|=%-1 A@@vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r<   r   r   r   r   r   r   r   r   r   r   r   s       r   
test_log1pzTestMathLib.test_log1p$  [    ;U[<u|=%-1 A@@vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r>   r   r   r   r   r   r   r   r   r   r   r   s       r   
test_log10zTestMathLib.test_log10,  r   r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r@   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_log2zTestMathLib.test_log24  s[    ;U[<u|=%-1 A@@vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S 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_asin<  r   r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_acoszTestMathLib.test_acosD  r   r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r!   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_atanzTestMathLib.test_atanL  sZ    ;U[<u|=%-1 100vw11111r   c                    t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}d |D             }| 
                    ||||           d S )Nr   c                     g | ]}|d z  S r   rm   .0r   s     r   
<listcomp>z*TestMathLib.test_atan2.<locals>.<listcomp>Z      ,,,aAE,,,r   )r#   r   r   r   r   r   r   r   r   r   r   rt   r   r   r   r   s        r   
test_atan2zTestMathLib.test_atan2T  so    ;U[<u|=%-1 100,,8,,,8<<<<<r   c                    t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||d           d S )Nr   doubler   )r'   r   r   r   r   r   r   r   r   r   r   r   s       r   
test_asinhzTestMathLib.test_asinh]  s^    ;U[<u|=%-1 .--vwx@@@@@r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r*   r   r   r   r   r   r   r   r   r   r   r   s       r   
test_acoshzTestMathLib.test_acoshe  sZ    ;U[<u|=%-1 .--vw11111r   c                    t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||d           d S )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_atanhm  s^    ;U[<u|=%-1 0//vwx@@@@@r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_sinhzTestMathLib.test_sinhu  r   r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )r   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_coshzTestMathLib.test_cosh}  r   r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S )Nr   )r   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_tanhzTestMathLib.test_tanh  Z    ;U[<u|=%-1 0//vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S N)r   r   r   r   r   r   r   gffffff?)rB   r   r   r   r   r   r   r   r   r   r   r   s       r   
test_floorzTestMathLib.test_floor  Z    ;U[<u|=%-1 0//vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )rD   r   r   r   r   r   r   r   r   r   r   r   s       r   	test_ceilzTestMathLib.test_ceil  r   r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )rF   r   r   r   r   r   r   r   r   r   r   r   s       r   
test_trunczTestMathLib.test_trunc  r   r   c                 :    |                      t                     d S r	   )r   rH   rt   s    r   
test_isnanzTestMathLib.test_isnan      !!%(((((r   c                 :    |                      t                     d S r	   )r   rJ   r   s    r   
test_isinfzTestMathLib.test_isinf  r   r   c                 :    |                      t                     d S r	   )r   rL   r   s    r   test_isfinitezTestMathLib.test_isfinite  s    !!(+++++r   c           	         t           }t          j        t          j        t          j        t          j        g}g d}d |D             }d}|                     |||||           d }t          |          }t          j        t          j        fD ]}t          j	        |          j
        }	 |	t          j        |	          j        dz            }
 ||
|
          }|                     | ||
|
          d           |                     t          j        |                     t#          j                    5  t#          j        dt(                     |                     t(          d||
|
           d d d            n# 1 swxY w Y   d S )	N)r   r   r            zG?(\?c                     g | ]}|d z   S r   rm   r   s     r   r   z*TestMathLib.test_hypot.<locals>.<listcomp>  r   r   ry   c                 <    t          j        | | z  ||z  z             S r	   r.   rO   s     r   naive_hypotz+TestMathLib.test_hypot.<locals>.naive_hypot  s    9QUQU]+++r   g      >@r   errorz overflow encountered in .*scalar)rN   r   r   r   r   r   r   r   r   as_dtypetyper1   finfomaxrr   
assertTruerL   warningscatch_warningssimplefilterRuntimeWarningassertRaisesRegex)rt   r   r   r   r   r|   r  ru   flttydtvalnb_anss               r   
test_hypotzTestMathLib.test_hypot  s   ;=%-1///,,8,,,8TBBB	, 	, 	, VmU]3 	? 	?E'..3B"RXb\\%+,,CU3__F##FFF3,<,<8#LLLOOBK//000(** ? ?%g~>>>&&~(J(3S#? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ?	? 	?s   39E88E<	?E<	c                    t           }t          j        t          j        t          j        t          j        t          j        t          j        g}g d}d |D             }d |D             }|                     ||||           |                     ||||           |                     ||g dt          j
        gdz             |                     ||g dt          j
         gdz             |                     ||||           d S )N)r   r   r   g%.AgS9c                     g | ]}|d z   S r   rm   r   s     r   r   z.TestMathLib.test_nextafter.<locals>.<listcomp>      ---qQU---r   c                     g | ]}|d z
  S r   rm   r   s     r   r   z.TestMathLib.test_nextafter.<locals>.<listcomp>  r  r   )r               ?r   )rQ   r   r   r   r   r   r   r   r   r
   r   )rt   r   r   r   	y1_values	y2_valuess         r   test_nextafterzTestMathLib.test_nextafter  s    =%-;</ 988--H---	--H---	9===9=== 	$(AFFF48)QGGG 	8<<<<<r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )rS   r   r   r   r   r   r   r   r   r   r   r   s       r   test_degreeszTestMathLib.test_degrees  Z    ;U[<u|=%-1 .--vw11111r   c                     t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}| 
                    |||           d S r   )rV   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  }|                     |||d	d
           d S )Nr                r   r  r   r   r   r   r|   ulps)rX   r   r   r   r   lenr   r   s       r   test_erfzTestMathLib.test_erf  sc    CsCE%LLA=%-0CMMQ4FGvwxaHHHHHr   c           
          t           }dddddddt          d          g}t          j        t          j        gt          |          dz  z  }|                     |||d	d
           d S )Nr   r#  r$  r   r  r   r   r   r   r   r%  )rZ   r   r   r   r   r'  r   r   s       r   	test_erfczTestMathLib.test_erfc  sc    CsCE%LLA=%-0CMMQ4FGvwxaHHHHHr   c                 >   t           }g d}t          j        t          j        gt	          |          dz  z  }|                     |||dd           dddd	d
t          d          g}t          j        gt	          |          z  }|                     |||dd           d S )N)r   r  r  r   r   r   r%  皙r         @g333333$@g      I@r      )r\   r   r   r   r'  r   r   r   s       r   
test_gammazTestMathLib.test_gamma  s    (((=%-0CMMQ4FGvwxaHHH#sD#uU||<=/CMM1vwxaHHHHHr   c           
          t           }dddddddt          d          g}t          j        t          j        gt          |          d	z  z  }|                     |||d
           d S )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  sa    dCtT5<<H=%-0CMMQ4FGvwx@@@@@r   c                    t           }t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j	        g}g d}d |D             }| 
                    ||||           d S )Nr   c                     g | ]}|d z  S r   rm   r   s     r   r   z(TestMathLib.test_pow.<locals>.<listcomp>  r   r   )r`   r   r   r   r   r   r   r   r   r   r   r   s        r   test_powzTestMathLib.test_pow	  so    ;U[<u|=%-1 100,,8,,,8<<<<<r   c                 .   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)r   r   r   r   r      r   r   )r   r   r   r:  	      )	itertoolsr7  r8  r9  rc   sortedr   signed_domainunsigned_domainr   r   )
rt   r7  r8  r9  r   signed_argsunsigned_argsr   r   r   s
             r   test_gcdzTestMathLib.test_gcd  s    4444444444g5&''
*0&1I1*M*M
 
 
  5())
,2F3F,J,J
 
 
 '*55m+L+L&M#88<<<<<r   c                 4   t           }t          j        t          j        g}ddddddt	          d          t	          d          t	          d	          g	}t          t          t          j        |||                     \  }}}| 	                    ||||           d S )
Nr   r   r$  r   r   r   -infr   r   )
re   r   r   r   r   listr   r=  r7  r   )rt   r   value_typesvaluesr   r   r   s          r   test_copysignzTestMathLib.test_copysign  s    }em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}|                     |||d	           d S )
Ng      r$  r   g      @rE  r   r   rw   r   )rg   r   r   r   r   r   r   s       r   
test_frexpzTestMathLib.test_frexp'  s^    =%-0$S&MM5<<u?vww?????r   c                     t           }t          |          }t          j        t          j        fD ]^}ddddddt          d          dft          d	          dft          d
          dff	D ]#}d|}|                      ||  ||            $_d S )N)r.  r   )r.  r   )r   r   )r   r   )r$  r   )r$  r   r   r   rE  r   rz   )ri   r   r   r   r   r   rr   )rt   r   ru   r  argsr}   s         r   
test_ldexpzTestMathLib.test_ldexp.  s    VmU]3 	E 	EE"Hh"I,,*U6]]A,>,,*, E E )-.''tffdmDDDDE	E 	Er   N)rw   )6__name__
__module____qualname__rv   r   r   r   r   unittestskipIfsysplatformr   r   r   r   r   
skipUnlessr   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*  r0  r2  r5  rC  rI  rK  rN  rm   r   r   rp   rp      s/       : : :. . . .N N N N2 2 22 2 2 X_S\W,>@ @2 2@ @22 2 22 2 2	2 	2 	22 2 2 Xg-/CDD2 2 ED22 2 22 2 22 2 22 2 22 2 22 2 22 2 22 2 2= = =A A A2 2 2A A A2 2 22 2 22 2 22 2 22 2 22 2 2) ) )) ) ), , ,? ? ?:= = =&2 2 22 2 2I I II I II I IA A A= = =
= 
= 
== = =@ @ @	E 	E 	E 	E 	Er   rp   __main__)=r=  r
   rT  rR  r
  numpyr1   numbar   r   numba.tests.supportr   numba.npr   numba.core.utilsr   r   r   r   r   r   r   r   r   r!   r#   r'   r*   r,   r/   r2   r4   r6   r8   r:   r<   r>   r@   rB   rD   rF   rH   rJ   rL   rN   rQ   rS   rV   rX   rZ   r\   r^   r`   rc   re   rg   ri   rn   rp   rO  mainrm   r   r   <module>r^     sf        



               ( ( ( ( ( ( " " " " " " & & & & & &                                                                                       DE DE DE DE DE( DE DE DEN zHMOOOOO r   