
    pir,                         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	 d dl
Z
ddiZddiZ G d	 d
e      Z G d dee      Z G d dee      Zedk(  r e
j$                          yy)    N)jittypes)TestCaseskip_if_py314   )*forceobjTnopythonc                   8    e Zd Zd Zd Zd ZddefdZdefdZy)BaseComplexTestc           
          ddddddt        d      t        d      g}t        j                  d	k7  r|t        d
      gz  }t        j                  ||      D cg c]  \  }}t        ||       c}}S c c}}w )N               r         ?g      -inf+infwin32nan)floatsysplatform	itertoolsproductcomplexselfrealsxys       Z/opt/services/ai/voice_agent/venv/lib/python3.12/site-packages/numba/tests/test_complex.pybasic_valueszBaseComplexTest.basic_values   sj    tQD$vf/<<7"eEl^#E*3*;*;E5*IJ$!Q1JJJs   A2c           
      ,   ddddt         j                   t         j                  t        d      t        d      g}t        j                  dk7  r|t        d      gz  }t        j                  ||      D cg c]  \  }}t        ||       c}}S c c}}w )	Nr   r   r   r   r   r   r   r   )mathpir   r   r   r   r   r   r   s       r!   more_valueszBaseComplexTest.more_values   sv    tQTWWHtwwhvf/<<7"eEl^#E*3*;*;E5*IJ$!Q1JJJs   6Bc           
          ddddt         j                   t         j                  t        d      t        d      g}t        j                  ||      D cg c]  \  }}t        ||       c}}S c c}}w )Nr   r   r   r   infr   )r$   r%   r   r   r   r   r   s       r!   non_nan_valueszBaseComplexTest.non_nan_values   sZ    tQTWWHtwwhuuV}.*3*;*;E5*IJ$!Q1JJJs   A.r   Nc           
      T   |D ]r  } t        |ffi ||      }|t        j                  t        j                  fv rdnd}	|D ]2  }
	  ||
      } ||
      }d|
d|	}| j                  |||	|||       4 t y # t        $ r%}| j                  dt        |             Y d }~ad }~ww xY w)Nsingledoublemath domain error
for input  with prec )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   s                  r!   	run_unaryzBaseComplexTest.run_unary#   s     	MB'C''/E!emmU__%EE88D 	M%bzH Bi57>''XD-17 ( M	M	M " MM"5s1v>s   A99	B'B""B'c           	         |D ]  \  }} t        ||ffi ||      }t        ||g      t        t        j                  t        j                  g      z  rdnd}	|D ]8  \  }
}	  ||
|      } ||
|      }d|
|fd|	}| j                  |||	||       :  y # t
        $ r%}| j                  dt        |             Y d }~gd }~wt        $ r Y uw xY w)Nr+   r,   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   s                   r!   
run_binaryzBaseComplexTest.run_binary3   s    ! 	<FB*CR*E*62EB8}sEMM5??+K'LL !  ! <B%b"~H Bm68"XtD''XD-1s ( <<	< " MM"5s1v>( s   !	B	C!CCC)	__name__
__module____qualname__r"   r&   r)   enable_pyobj_flagsrD   rL        r!   r   r      s1    KKK
 9:4*M  <=+<rR   r   c                   V    e Zd ZefdZd ZefdZd ZefdZd Z	efdZ
ed        Zy	)
TestComplexc                 r   | j                  t        t        j                  t        j                  g| j                         |       | j                  t        t        j                  t        j                  gg d|       | j                  t        t        j                  t        j                  gddg|       y Nr=   )r   r   r   g      )
rD   real_usecaser   r5   
complex128r"   int8int64r4   float64r   r=   s     r!   	test_realzTestComplex.test_realJ       |eoou7G7G%H((*% 	 	9|ejj%++%>! 	 	0|emmU]]%CT{% 	 	1rR   c                 0    | j                  t               y NrW   )r_   no_pyobj_flagsr   s    r!   test_real_npmzTestComplex.test_real_npmR       ^,rR   c                 r   | j                  t        t        j                  t        j                  g| j                         |       | j                  t        t        j                  t        j                  gg d|       | j                  t        t        j                  t        j                  gddg|       y rV   )
rD   imag_usecaser   r5   rZ   r"   r[   r\   r4   r]   r^   s     r!   	test_imagzTestComplex.test_imagU   r`   rR   c                 0    | j                  t               y rb   )ri   rc   rd   s    r!   test_imag_npmzTestComplex.test_imag_npm]   rf   rR   c                 r   | j                  t        t        j                  t        j                  g| j                         |       | j                  t        t        j                  t        j                  gg d|       | j                  t        t        j                  t        j                  gddg|       y rV   )
rD   conjugate_usecaser   r5   rZ   r"   r[   r\   r4   r]   r^   s     r!   test_conjugatezTestComplex.test_conjugate`   s    (5??E<L<L*M((*% 	 	9(5::u{{*C! 	 	0(5==%--*HT{% 	 	1rR   c                 0    | j                  t               y rb   )rn   rc   rd   s    r!   test_conjugate_npmzTestComplex.test_conjugate_npmh   s    .1rR   c                 ,   t        t        j                  | j                         | j                                     }t        j
                  t        j
                  ft        j                  t        j                  fg}| j                  t        |||       y)zN
        Test complex.__div__ implementation with non-trivial values.
        rW   N)	listr   r   r&   r   rZ   r5   rL   div_usecaser   r=   rI   rH   s       r!   test_divzTestComplex.test_divk   sl    
 i''(8(8(:D<L<L<NOP((%*:*:;9;[&FrR   c                 0    | j                  t               y rb   )ru   rc   rd   s    r!   test_div_npmzTestComplex.test_div_npmu   s    N+rR   N)rM   rN   rO   rP   r_   re   ri   rk   rn   rp   ru   r   rw   rQ   rR   r!   rT   rT   H   sL    0 1- 1 1- $6 12 0 G , ,rR   rT   c                   T   e Zd ZdZd Z	 	 d3dZd Zd Zd Zd Z	e
fd	Zd
 Ze
fdZd Ze
fdZd Ze
fdZd Zd Zd Zd Zd Ze
fdZe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 Z5y)4	TestCMathz)
    Tests for cmath module support.
    c                     | j                  |t        j                  t        j                  g| j	                         |       y rb   )rD   r   rZ   r5   r"   )r   r:   r=   s      r!   check_predicate_funczTestCMath.check_predicate_func   s4    v 0 0%//B((*% 	 	9rR   Nc                     | j                  |t        j                  g|xs | j                         |||       | j                  |t        j                  g|xs | j                         |||       y )N)r=   r1   r2   )rD   r   rZ   r&   r5   r"   )r   r:   r=   r1   r2   rI   s         r!   check_unary_funczTestCMath.check_unary_func   sn    v 0 013!1!1!35t& 	 	( 	v04!2!2!4E& 	 	(rR   c                 8    | j                  t        t               y N)r}   phase_usecaserP   rd   s    r!   
test_phasezTestCMath.test_phase       m-?@rR   c                 8    | j                  t        t               y r   )r}   r   rc   rd   s    r!   test_phase_npmzTestCMath.test_phase_npm       m^<rR   c                 8    | j                  t        t               y r   )r}   polar_usecaserP   rd   s    r!   
test_polarzTestCMath.test_polar   r   rR   c                 8    | j                  t        t               y r   )r}   r   rc   rd   s    r!   test_polar_npmzTestCMath.test_polar_npm   r   rR   c                       fd} |t         j                   j                                 |t         j                   j	                                y )Nc                     |D cg c]H  }t        j                  |j                        r|j                  dk(  r|j                  |j                  fJ }}j	                  t
        | | fg|       y c c}w )Nr   rW   )r$   isinfimagrealrL   rect_usecase)tpseed_valueszrI   r=   r   s       r!   do_testz$TestCMath.test_rect.<locals>.do_test   si    0; @1!ZZ/166Q; vvqvv& @F @OOLB8*fEOJ@s   AA2)r   r]   r&   r4   r"   )r   r=   r   s   `` r!   	test_rectzTestCMath.test_rect   s9    	K 	t//12t0023rR   c                 0    | j                  t               y rb   )r   rc   rd   s    r!   test_rect_npmzTestCMath.test_rect_npm   rf   rR   c                 8    | j                  t        t               y r   )r{   isnan_usecaserP   r^   s     r!   
test_isnanzTestCMath.test_isnan       !!-1CDrR   c                 8    | j                  t        t               y r   )r{   r   rc   rd   s    r!   test_isnan_npmzTestCMath.test_isnan_npm       !!-@rR   c                 8    | j                  t        t               y r   )r{   isinf_usecaserP   r^   s     r!   
test_isinfzTestCMath.test_isinf   r   rR   c                 8    | j                  t        t               y r   )r{   r   rc   rd   s    r!   test_isinf_npmzTestCMath.test_isinf_npm   r   rR   c                 8    | j                  t        t               y r   )r{   isfinite_usecaserP   r^   s     r!   test_isfinitezTestCMath.test_isfinite   s    !!"24FGrR   c                 8    | j                  t        t               y r   )r{   r   rc   rd   s    r!   test_isfinite_npmzTestCMath.test_isfinite_npm   s    !!"2NCrR   c                 <    | j                  t        t        d       y N   )r1   )r}   exp_usecaserP   rd   s    r!   test_expzTestCMath.test_exp       k+=AFrR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_exp_npmzTestCMath.test_exp_npm   s     	k>BrR   c                 8    | j                  t        t               y r   )r}   log_usecaserP   rd   s    r!   test_logzTestCMath.test_log   s    k+=>rR   c                 8    | j                  t        t               y r   )r}   r   rc   rd   s    r!   test_log_npmzTestCMath.test_log_npm   s    k>:rR   c                 .   t        t        j                  | j                         | j                                     }t        j
                  t        j
                  ft        j                  t        j                  fg}| j                  t        |||d       y )N   )r=   r1   )	rr   r   r   r&   r   rZ   r5   rL   log_base_usecasert   s       r!   test_log_basezTestCMath.test_log_base   ss    i''(8(8(:D<L<L<NOP((%*:*:;9;(+vU 	 	 rR   c                 0    | j                  t               y rb   )r   rc   rd   s    r!   test_log_base_npmzTestCMath.test_log_base_npm   s    0rR   c                 8    | j                  t        t               y r   )r}   log10_usecaserP   rd   s    r!   
test_log10zTestCMath.test_log10   r   rR   c                 8    | j                  t        t               y r   )r}   r   rc   rd   s    r!   test_log10_npmzTestCMath.test_log10_npm   r   rR   c                 8    | j                  t        t               y r   )r}   sqrt_usecaserP   rd   s    r!   	test_sqrtzTestCMath.test_sqrt   s    l,>?rR   c                     | j                  t        t               t        dd      D cg c]  }d|z   
 }}| j	                  t        t
        j                  g|t               y c c}w )N$   )   
   rW   )r}   r   rc   rangerD   r   rZ   )r   irI   s      r!   test_sqrt_npmzTestCMath.test_sqrt_npm   s[    lN; %*"bM2q27(22|e&6&6%7^ 	 	5 3s   A%c                 <    | j                  t        t        d       y r   )r}   acos_usecaserP   rd   s    r!   	test_acoszTestCMath.test_acos       l,>QGrR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_acos_npmzTestCMath.test_acos_npm       lNCrR   c                 <    | j                  t        t        d       y r   )r}   asin_usecaserP   rd   s    r!   	test_asinzTestCMath.test_asin   r   rR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_asin_npmzTestCMath.test_asin_npm   r   rR   c                 <    | j                  t        t        d       y r   )r}   atan_usecaserP   rd   s    r!   	test_atanzTestCMath.test_atan   s    l,>QHrR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_atan_npmzTestCMath.test_atan_npm   s    lNDrR   c                 <    | j                  t        t        d       y r   )r}   cos_usecaserP   rd   s    r!   test_coszTestCMath.test_cos   r   rR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_cos_npmzTestCMath.test_cos_npm   s    k>BrR   c                 <    | j                  t        t        d       y Neps)r2   )r}   sin_usecaserP   rd   s    r!   test_sinzTestCMath.test_sin  s    k+=uMrR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_sin_npmzTestCMath.test_sin_npm  s    k>5IrR   c                 <    | j                  t        t        d       y r   r}   tan_usecaserP   rd   s    r!   test_tanzTestCMath.test_tan	  r   rR   c                 <    | j                  t        t        d       y r   r   rd   s    r!   test_tan_npmzTestCMath.test_tan_npm  r   rR   c                 8    | j                  t        t               y r   )r}   acosh_usecaserP   rd   s    r!   
test_acoshzTestCMath.test_acosh  r   rR   c                 8    | j                  t        t               y r   )r}   r   rc   rd   s    r!   test_acosh_npmzTestCMath.test_acosh_npm  r   rR   c                 <    | j                  t        t        d       y r   )r}   asinh_usecaserP   rd   s    r!   
test_asinhzTestCMath.test_asinh      m-?aHrR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_asinh_npmzTestCMath.test_asinh_npm      m^!DrR   c                 <    | j                  t        t        d       y r   )r}   atanh_usecaserP   rd   s    r!   
test_atanhzTestCMath.test_atanh  r   rR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_atanh_npmzTestCMath.test_atanh_npm   r   rR   c                 <    | j                  t        t        d       y r   )r}   cosh_usecaserP   rd   s    r!   	test_coshzTestCMath.test_cosh#  r   rR   c                 <    | j                  t        t        d       y r   )r}   r   rc   rd   s    r!   test_cosh_npmzTestCMath.test_cosh_npm&  r   rR   c                 <    | j                  t        t        d       y r   )r}   sinh_usecaserP   rd   s    r!   	test_sinhzTestCMath.test_sinh)  s    l,>NrR   c                 <    | j                  t        t        d       y r   )r}   r  rc   rd   s    r!   test_sinh_npmzTestCMath.test_sinh_npm,  s    lNEJrR   c                 <    | j                  t        t        d       y r   r}   tanh_usecaserP   rd   s    r!   	test_tanhzTestCMath.test_tanh/  r   rR   c                 <    | j                  t        t        d       y r   r
  rd   s    r!   test_tanh_npmzTestCMath.test_tanh_npm2  r   rR   )r   NN)6rM   rN   rO   __doc__r{   r}   r   r   r   r   rP   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  rQ   rR   r!   ry   ry   z   sK   9 ?C $(A=A= 1 4-
  2 EA  2 EA #5 HD
GC?; #5   1 1A=@5HDHDIEGCNJGG
A=IEIEHDOKHHrR   ry   __main__)r   r$   r   numbar   r   numba.tests.supportr   r   complex_usecasesunittestrP   rc   objectr   rT   ry   rM   mainrQ   rR   r!   <module>r     sx      
  7   $' d#7<f 7<t/,/8 /,dyH yHx zHMMO rR   