+
    ;i:\                         ^ RI t ^ RIt^ RIHtHt ^ RIHt ^ RIHt  ! R R4      t	 ! R R]4      t
]R	8X  d   ]P                  ! 4        R# R# )
    N)TestCasecaptured_stdout)IS_WIN32)numpy_versionc                   .   a  ] tR t^t o RtRR ltRtV tR# )MatplotlibBlockerzBlocks the import of matplotlib, so that doc examples that attempt to
plot the output don't result in plots popping up and blocking testing.Nc                .    VR 8X  d   Rp\        V4      hR# )
matplotlibz/Blocked import of matplotlib for test suite runN)ImportError)selffullnamepathtargetmsgs   &&&& d/var/www/html/photoedit/myenv/lib/python3.14/site-packages/numba/tests/doc_examples/test_examples.py	find_specMatplotlibBlocker.find_spec   s    |#CCc"" $     N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classdictcell__)__classdict__s   @r   r   r      s     N# #r   r   c                      a a ] tR t^t oV 3R ltR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tRtVtV ;t# )DocsExamplesTestc                F   < \         SV `  ! V/ VB  \        4       V n        R # r   )super__init__r   _mpl_blocker)r   argskwargs	__class__s   &*,r   r#   DocsExamplesTest.__init__   s     $)&)-/r   c                Z    \         P                  P                  ^ V P                  4       R# r   N)sys	meta_pathinsertr$   r   s   &r   setUpDocsExamplesTest.setUp   s    Q 1 12r   c                X    \         P                  P                  V P                  4       R # r   )r+   r,   remover$   r.   s   &r   tearDownDocsExamplesTest.tearDown   s    T../r   c           
       a \        4       ;_uu_ 4        ^ RIHp  ^ RIHpHp Rp^ RIp^ RIH	p V! RR7      R 4       oV! RR7      V3R	 l4       pVP                  RVP                  R
7      pV! 4       p	V! RRRRV^4       V! 4       p
\        W,
          4       V'       d   X! V4       X! 4        RRR4       R#   \         d    Rp Li ; i  + '       g   i     R# ; i)r   )default_timer)imshowshowTFNjitnopythonc                    ^ p\        W4      pRp\        V4       FZ  pWU,          V,           pVP                  VP                  ,          VP                  VP                  ,          ,           ^8  g   KX  Vu # 	  ^# )z
Given the real and imaginary parts of a complex number,
determine if it is a candidate for membership in the Mandelbrot
set given a fixed number of iterations.
y                )complexrangerealimag)xy	max_itersiczs   &&&   r   mandel0DocsExamplesTest.test_mandelbrot.<locals>.mandel.   s`     ALy)A	A!&&166/9a?  *
 r   c                 0  < VP                   ^ ,          pVP                   ^,          pW,
          V,          pW2,
          V,          p	\        V4       FA  p
W
V,          ,           p\        V4       F   pW,V	,          ,           pS! WV4      pWW3&   K"  	  KC  	  V# )r   )shaper?   )min_xmax_xmin_ymax_yimageitersheightwidthpixel_size_xpixel_size_yrB   r@   rC   rA   colorrH   s   &&&&&&         r   create_fractal8DocsExamplesTest.test_mandelbrot.<locals>.create_fractal?   s    QA %6 %7uA |#33D"6]$<'77 &t5 9&+ad + & r   dtype      ?)  i  g       g      )r   timeitr6   matplotlib.pylabr7   r8   r   numpynumbar:   zerosuint8print)r   timerr7   r8   have_mplnpr:   rW   rP   serH   s   &          @r   test_mandelbrot DocsExamplesTest.test_mandelbrot"   s    5!9 !$    $   HH/rxxH@EA4dC;A!%Lug   ! ! s.   C
B;BC;CC
CCC	c                ,   \        4       ;_uu_ 4        ^ RIp^ RIHp V! R.R4      R 4       pVP	                  ^VP
                  R7      P                  ^^
4      p\        V4       \        V! V^4      4       RRR4       R#   + '       g   i     R# ; i)r   Nguvectorizez%void(float64[:], intp[:], float64[:])(n),()->(n)c                    V^ ,          pRp^ p\        V4       F%  pW@V,          ,          pV^,          pWE,          W&&   K'  	  \        V\        V 4      4       F0  pW@V,          WV,
          ,          ,
          ,          pWE,          W&&   K2  	  R# )r           N)r?   len)a
window_arroutwindow_widthasumcountrE   s   &&&    r   	move_mean7DocsExamplesTest.test_moving_average.<locals>.move_mean`   s|      *!}|,AaDLDQJE!\CF - |SV4AaD1%5#666D!\CF 5r   rY   )r   r_   r`   rm   arangefloat64reshaperc   )r   rf   rm   rx   arrs   &    r   test_moving_average$DocsExamplesTest.test_moving_averageY   s{    )AB&(
*(
* ))Bbjj)199!R@C#J)C#$- s   A%BB	c           	       aaaa \        4       ;_uu_ 4        ^ RIo^ RIo^ RIHo ^ RIo^ RIHp ^pRpV3R lpV! RRRR7      V3R l4       pVV3R	 lpV3R
 lpVV3R lpV! V4      p	V! WR4      p
SP                  P                  V4      pSP                  P                  V4      pV! RRWKV4      pV! VRWV4       V! VRV,          WV4       RRR4       R#   + '       g   i     R# ; i)r   N)repeatr9   c                P   < SP                  RV ,          RV,          ,           4      # )z
Control function using Numpy.
 @皙	@)exp)rr   brf   s   &&r   func_np,DocsExamplesTest.test_nogil.<locals>.func_np   s!     vvcAga/00r   z%void(double[:], double[:], double[:])T)r<   nogilc                   < \        \        V 4      4       F7  pSP                  RW,          ,          RW#,          ,          ,           4      W&   K9  	  R# )z
Function under test.
r   r   N)r?   rq   r   )resultrr   r   rE   maths   &&& r   inner_func_nb2DocsExamplesTest.test_nogil.<locals>.inner_func_nb   s9     s6{+A $qtcADj)@ AFI ,r   c                  <aaa \        VP                  ^4      RR7       S! S/ SB pV e    SP                  WP4      '       g	   Q WP34       h\        RP                  \	        S! VVV3R l^^R7      4      R,          4      4       V# )z-
Benchmark *func* and print out its runtime.
 )endz{:>5.0f} msc                     < S! S / SB # r   r   )r%   funcr&   s   r   <lambda>?DocsExamplesTest.test_nogil.<locals>.timefunc.<locals>.<lambda>   s    D$1&1r   )numberr   r\   )rc   ljustallcloseformatmin)correctrg   r   r%   r&   resrf   r   s   &&fjl r   timefunc-DocsExamplesTest.test_nogil.<locals>.timefunc   s     aggbks+ D+F+&;;s44DsnD4m**3v1!A0G ,HJN,O P Q
r   c                   <a  V V3R lpV# )z0
Run the given function inside a single thread.
c                  z   < \        V ^ ,          4      pSP                  VSP                  R7      pS! V.V O5!   V# )r   rY   )rq   emptyr{   )r%   lengthr   
inner_funcrf   s   *  r   r   DDocsExamplesTest.test_nogil.<locals>.make_singlethread.<locals>.func   s8     a\FXXfBJJX?Fv--!Mr   r   )r   r   rf   s   f r   make_singlethread6DocsExamplesTest.test_nogil.<locals>.make_singlethread   s    "
 r   c                   <a a V VVV3R lpV# )zf
Run the given function inside *numthreads* threads, splitting
its arguments into equal-sized chunks.
c                    < \        V ^ ,          4      pSP                  VSP                  R7      pV3V ,           p VS,           ^,
          S,          p\        S4       UUu. uF*  q@ Uu. uF  qUWC,          V^,           V,           NK  	  upNK,  	  pppV Uu. uF  pSP	                  S
VR7      NK  	  ppV F  p	V	P                  4        K  	  V F  p	V	P                  4        K  	  V# u upi u uppi u upi )r   rY   )r   r%   )rq   r   r{   r?   Threadstartjoin)r%   r   r   chunklenrE   argchunkschunkthreadsthreadr   rf   
numthreads	threadings   *         r   func_mtFDocsExamplesTest.test_nogil.<locals>.make_multithread.<locals>.func_mt   s    a\FXXfBJJX?F"9t+D & 3a 7JFH /4J.?A.?t%# IL1<Q(0BC#%.?  A -34,25  )//z/N,2  4") #*") #*!M% A4s    C.(!C)	C.C4)C.r   )r   r   r   rf   r   s   ff r   make_multithread5DocsExamplesTest.test_nogil.<locals>.make_multithread   s    
" "  r   znumpy (1 thread)znumba (1 thread)znumba (%d threads)i@B )
r   r   r   r]   r   r_   r`   r:   randomrand)r   r:   nthreadssizer   r   r   r   r   func_nb
func_nb_mtrr   r   r   r   rf   r   r   s   &             @@@@r   
test_nogilDocsExamplesTest.test_nogils   s    %!HD1 84BB	. (6G)-BJ		t$A		t$At%7QGGW0'a@W2X=zaPi s   B9CC+	c                    \        4       ;_uu_ 4        ^ RIHpHp V! V! W"4      .4      R 4       pRRR4       R#   + '       g   i     R# ; i)r   )	vectorizer{   c                     W,           # r   r   rB   rC   s   &&r   f8DocsExamplesTest.test_vectorize_one_signature.<locals>.f   	    ur   N)r   r`   r   r{   )r   r   r{   r   s   &   r   test_vectorize_one_signature-DocsExamplesTest.test_vectorize_one_signature   s<    0123 4 s	   ;A	c                   \        4       ;_uu_ 4        ^ RIHpHpHpHpHp ^ RIpV! V! W"4      V! W34      V! WD4      V! WU4      .4      R 4       pVP                  ^4      pV! W4      p	V P                  WP                  4       VP                  . RO4      p
VP                  P                  W4       VP                  ^ ^^4      pV! W4      p	V P                  WP                  4       VP                  . RO4      p
VP                  P                  W4       VP                  ^4      P!                  ^^4      pVP#                  V^ R7      pVP#                  V^R7      pVP%                  V4      pVP%                  V^R7      pV P                  WP                  4       VP                  . RO4      p
VP                  P                  W4       V P                  WP                  4       VP                  . RO4      p
VP                  P                  W4       V P                  WP                  4       VP                  . R	O. R
O. RO.4      p
VP                  P                  W4       V P                  WP                  4       VP                  . RO. RO. RO.4      p
VP                  P                  W4       RRR4       R#   + '       g   i     R# ; i)r   )r   int32int64float32r{   Nc                     W,           # r   r   r   s   &&r   r   >DocsExamplesTest.test_vectorize_multiple_signatures.<locals>.f   s    
 ur   )axis)r               
   )rp   g?g?g333333?g?       @)            )r      &   )r      r      )r   r   r   r   )r   r   r   r   )r   	   r   r   )r         r   )r   r`   r   r   r   r   r{   r_   rz   assertIsInstancendarrayarraytestingassert_array_equallinspaceassert_allcloser|   reduce
accumulate)r   r   r   r   r   r{   rf   r   rr   r   r   result1result2result3result4s   &              r   "test_vectorize_multiple_signatures3DocsExamplesTest.test_vectorize_multiple_signatures   sP   GGe+e+113 4	4
 		!AqWF !!&**5hh23GJJ))&: Aq!$AqWF !!&**5hh<=GJJ&&v7 		"%%a+A
 hhqqh)G hhqqh)G ll1oG
 ll11l-G !!'::6hh/0GJJ))';!!'::6hh{+GJJ))';!!'::6hh   G
 JJ))';!!'::6hh  G
 JJ))';] s   J J==K	c           	     n   \        4       ;_uu_ 4        ^ RIHpHp ^ RIpV! VR,          W"R,          3.R4      R 4       pVP                  ^4      pV! V^4      pV P                  WcP                  4       VP                  . RO4      pVP                  P                  Wg4       VP                  ^4      P                  ^^4      pV! V^
4      pV! WSP                  ^
^.4      4      p	V! WSP                  ^
^.4      4       V P                  WP                  4       VP                  . RO. RO.4      pVP                  P                  W4       V P                  WP                  4       VP                  . RO. R	O.4      pVP                  P                  W4       RRR4       R#   + '       g   i     R# ; i)
r   rm   r   NNNNrn   c                 n    \        V P                  ^ ,          4       F  pW,          V,           W#&   K  	  R# r*   r?   rK   rB   rC   r   rE   s   &&& r   g,DocsExamplesTest.test_guvectorize.<locals>.g,  &    qwwqz*ATAXCF +r   r   r   r      r   )r      r   )      r   )         )r   r`   rm   r   r_   rz   r   r   r   r   r   r|   )
r   rm   r   rf   r   rr   r   r   r   r   s
   &         r   test_guvectorize!DocsExamplesTest.test_guvectorize&  s`   058U!H56F& G& 		!Aq!WF !!&**5hh/GJJ))&: 		!$$Q*A 2hG 88RH-.Ga2r(#$
 !!'::6hhl;<GJJ))';!!'::6hhl;<GJJ))';U s   FF##F4	c                J   \        4       ;_uu_ 4        ^ RIHpHp ^ RIpV! VR,          W"R,          3.R4      R 4       pVP                  ^4      pV! V^4      pV P                  WcP                  4       V P                  V^4       RRR4       R#   + '       g   i     R# ; i)r   r   Nr   z
(n),()->()c                     ^ p\        V P                  ^ ,          4       F  pW0V,          V,           ,          pK  	  W2^ &   R# r*   r   )rB   rC   r   accrE   s   &&&  r   r   :DocsExamplesTest.test_guvectorize_scalar_return.<locals>.gY  s4    qwwqz*AQ4!8OC +Ar   )	r   r`   rm   r   r_   rz   r   integerassertEqual)r   rm   r   rf   r   rr   r   s   &      r   test_guvectorize_scalar_return/DocsExamplesTest.test_guvectorize_scalar_returnS  s    058U!H56E F 		!Aq!WF !!&**5VR() s   A4BB"	c                8  a \        4       ;_uu_ 4        ^ RIp^ RIHpHp V! R4      R 4       oV! RR7      V3R l4       pVP                  ^RR	7      pVP                  V4      pV! WV4       V P                  WV4       RRR4       R#   + '       g   i     R# ; i)
r   Nr:   rm   (n)->(n)c                 `    \        V P                  ^ ,          4       F  pW,          W&   K  	  R# r*   r   rB   r   rE   s   && r   copy3DocsExamplesTest.test_guvectorize_jit.<locals>.copyq  "    qwwqz*ATCF +r   Tr;   c                    < S! W4       R # r   r   rB   r   r  s   &&r   jit_fn5DocsExamplesTest.test_guvectorize_jit.<locals>.jit_fnv  
    Qr   i4rY   )r   r_   r`   r:   rm   rz   
zeros_likeassertPreciseEqual)r   rf   r:   rm   r  rB   r   r  s   &      @r   test_guvectorize_jit%DocsExamplesTest.test_guvectorize_jitj  s    .$" %" $  
 		!4	(A--"C1N ##A+- s   A*BB	c           	       a \        4       ;_uu_ 4        ^ RIp^ RIHpHp V! R4      R 4       oV! RR7      V3R l4       pVP                  R	4      pVP                  R
4      pV P                  \        4      ;_uu_ 4       pV! WV4       RRR4       V P                  R\        XP                  4      4       RRR4       R#   + '       g   i     L?; i  + '       g   i     R# ; i)r   Nr  r  c                 `    \        V P                  ^ ,          4       F  pW,          W&   K  	  R# r*   r   r  s   && r   r  8DocsExamplesTest.test_guvectorize_jit_fail.<locals>.copy  r  r   Tr;   c                    < S! W4       R # r   r   r  s   &&r   r  :DocsExamplesTest.test_guvectorize_jit_fail.<locals>.jit_fn  r  r   z&Loop and array shapes are incompatible)r   r   )r   )r   r_   r`   r:   rm   onesr   assertRaises
ValueErrorassertInstr	exception)	r   rf   r:   rm   r  rB   r   raisesr  s	   &       @r   test_guvectorize_jit_fail*DocsExamplesTest.test_guvectorize_jit_fail  s    .$" %" $   A((4.C"":..&q / MMBf../1'   /.! s$   A,C 	C 		-C CCC$	c                   \        4       ;_uu_ 4        ^ RIHpHp ^ RIpV! VR,          VR,          3.R4      R 4       pVP                  R
VP                  R7      pV! V4      pV P                  WSP                  4       VP                  . RO. RO. RO.4      pVP                  P                  WW4       V P                  WcP                  4       VP                  . RO. RO. RO.4      pVP                  P                  Wg4       VP                  R
VP                  R7      pV! V4      p\        V4       V P                  WSP                  4       VP                  . RO. RO. RO.VP                  R7      pVP                  P                  WW4       V P                  WcP                  4       VP                  . RO. RO. RO.4      pVP                  P                  Wg4       V! VR,          VR,          3.RRR7      R	 4       pVP                  R
VP                  R7      pV! V4      p\        V4       V P                  WSP                  4       VP                  . RO. RO. RO.4      pVP                  P                  WW4       V P                  WcP                  4       VP                  . RO. RO. RO.4      pVP                  P                  Wg4       RRR4       R#   + '       g   i     R# ; i)r   )rm   r{   Nr   z()->()c                     R V ^ &   RV^ &   R#       @@Nr   invalsoutvalss   &&r   init_values@DocsExamplesTest.test_guvectorize_overwrite.<locals>.init_values  s    q	 
r   )rK   rZ   rY   )writable_argsc                     R V ^ &   RV^ &   R# r-  r   r0  s   &&r   r3  r4    s      q	 
r   )r   r   )r.  r.  r.  )r/  r/  r/  )rp   rp   rp   )r1  )r   r`   rm   r{   r_   ra   r   r   r   r   r   r   rc   )r   rm   r{   rf   r3  r1  r2  r   s   &       r   test_guvectorize_overwrite+DocsExamplesTest.test_guvectorize_overwrite  s   271:wqz23X>! ?! XXF"**X=F
 "&)G !!&**5hh ! "G JJ))&:!!'::6hh ! "G JJ))'; XXF"**X=F "&)G &M !!&**5hh  &(ZZ  1G JJ))&:!!'::6hh ! "G JJ))'; !*gaj)*)
!
! XXF"**X=F "&)G &M !!&**5hh ! "G JJ))&:!!'::6hh ! "G JJ))';M s   K KK.	c                   \        4       ;_uu_ 4        ^ RIHp VR 4       pV! ^^4      p\        VP                  4       V P                  V^4       \        '       d   \        R8  d   R.pMR.pMR.pV P                  VP                  V4       V! RR4      p\        VP                  4       V P                  VR4       \        '       d   \        R8  d   RR.pM	RR.pMRR.pV P                  VP                  V4       V! ^R4      p\        VP                  4       V P                  VR4       \        '       d   \        R8  d   RR.pM	RR.pMRR.pV P                  VP                  V4       VR	 4       p\        V! RR
4      4       \        V! ^^4      4       \        VP                  4       R.pV P                  VP                  V4       RRR4       R#   + '       g   i     R# ; i)r   )r   c                     W,          # r   r   r   s   &&r   r   2DocsExamplesTest.test_vectorize_dynamic.<locals>.f  r   r   zll->qqq->qll->lr[   r   dd->dc                     W,          # r   r   )rr   r   s   &&r   r   2DocsExamplesTest.test_vectorize_dynamic.<locals>.gD  r   r   g      @N)r   r   )r   r`   r   rc   typesr  r   r   )r   r   r   r   r   r   s   &     r   test_vectorize_dynamic'DocsExamplesTest.test_vectorize_dynamic  s   ' 
 qVF !''N VR(x 6)&iG&iG")QWWg. r"XF !''N VS)x 6)&0G&0G"G,QWWg. qWF !''N VS)x 6)&0G&0G"G,QWWg.   !Br(O !Aa&M !''N iGQWWg._ s   F?GG-	c                   \        4       ;_uu_ 4        ^ RIHp ^ RIpV! R4      R 4       pVP	                  ^VP
                  R7      p^
pVP                  V4      pV! WEV4       \        VP                  4       VP                  . R
O4      pVP                  P                  Wg4       \        '       d   R.pMR.pV P                  VP                  V4       VP	                  ^VP                  R7      pRpVP                  V4      pV! WEV4       \        VP                  4       \        '       d   RR	.pMRR	.pV P                  VP                  V4       VP	                  ^VP
                  R7      p^pVP                  V4      pV! WEV4       \        V4       VP                  . RO4      pVP                  P                  Wg4       RRR4       R#   + '       g   i     R# ; i)r   rl   Nrn   c                 n    \        V P                  ^ ,          4       F  pW,          V,           W#&   K  	  R# r*   r   r   s   &&& r   r   4DocsExamplesTest.test_guvectorize_dynamic.<locals>.g[  r   r   rY   r<  r=  g@r>  )r   r   r   r   r   r   )r   r`   rm   r_   rz   r   r  rc   rA  r   r   r   r   r  double)r   rm   rf   r   rB   rC   r   r   s   &       r   test_guvectorize_dynamic)DocsExamplesTest.test_guvectorize_dynamicU  s   )'& (& 		!288	,AA--"CaCL!''N hh34GJJ))#7x")")QWWg. 		!299	-AA--"CaCL
 !''N x"G,"G,QWWg. 		!288	,AA--"CaCL#J hh/GJJ))#7u s   F5GG#	)r$   )r   r   r   r   r#   r/   r3   ri   r~   r   r   r   r  r	  r  r)  r7  rB  rH  r   r   __classcell__)r'   r   s   @@r   r    r       s`     0304n%4UQpO<b+<Z).,21.g<RP/d;8 ;8r   r    __main__)r+   unittestnumba.tests.supportr   r   numba.core.configr   numba.np.numpy_supportr   r   r    r   mainr   r   r   <module>rQ     sG      9 & 0# #z	8x z	8z zMMO r   