+
    ;i/!                       ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
Ht ^ RIt^ RIt^ RIt^ RIHtHtHt ^ RIHt ^ RIHtHtHt ^ RIH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)R t*R t+R t,R t-R t.R t/R t0R t1R t2R t3R  t4]3! R!4      t5]1! R"4      t6]2! R#4      t7]3! R$4      t8]1! R%4      t9]2! R&4      t:R' t;R( t<R) t=R* t>R+ t? ! R, R-]4      t@ ! R. R/]@4      tA ! R0 R1]@4      tB ! R2 R3]@4      tC ! R4 R5]@4      tD ! R6 R7]@4      tE ! R8 R9]@4      tF ! R: R;]@4      tG]! R<R<R=7      R> 4       tHRKtI]! R<R<R=7      R? 4       tJ ! R@ RA]4      tK ! RB RC]K4      tL]P                  ! ]P                  RD8H  RE4       ! RF RG]K4      4       tO ! RH RI]4      tP]QRJ8X  d   ]P                  ! 4        R# R# )L    N)dedent)jit
_helperlibnjit)types)TestCasecompile_functiontag)TypingErrorp  c                  ,    \         P                  ! 4       # N)r   rnd_get_py_state_ptr     U/var/www/html/photoedit/myenv/lib/python3.14/site-packages/numba/tests/test_random.pyget_py_state_ptrr          **,,r   c                  ,    \         P                  ! 4       # r   )r   rnd_get_np_state_ptrr   r   r   get_np_state_ptrr      r   r   c                 @    \         P                  P                  V 4      # r   nprandomrandintas   &r   numpy_randint1r   #   s    99Qr   c                 @    \         P                  P                  W4      # r   r   r   bs   &&r   numpy_randint2r#   &   s    99Q""r   c                 .    \         P                  ! W4      # r   )r   r   r!   s   &&r   random_randintr%   )   s    >>!r   c                 .    \         P                  ! V 4      # r   r   	randranger   s   &r   random_randrange1r)   ,   s    Ar   c                 .    \         P                  ! W4      # r   r'   r!   s   &&r   random_randrange2r+   /   s    A!!r   c                 0    \         P                  ! WV4      # r   r'   )r   r"   cs   &&&r   random_randrange3r.   2   s    A!$$r   c                 @    \         P                  P                  V 4      # r   r   r   choicer   s   &r   numpy_choice1r2   5   s    99Ar   c                 B    \         P                  P                  WR 7      # sizer0   )r   r6   s   &&r   numpy_choice2r7   8   s    99A))r   c                 D    \         P                  P                  WVR 7      # ))r6   replacer0   )r   r6   r9   s   &&&r   numpy_choice3r:   ;   s    99A'::r   c                 @    \         P                  P                  W4      # r   r   r   multinomial)npvalss   &&r   numpy_multinomial2r@   >   s    99  **r   c                 D    \         P                  P                  WVR 7      # ))r?   r6   r<   )r>   r?   r6   s   &&&r   numpy_multinomial3rB   A   s    99  d ;;r   c                 B    \         P                  P                  WR 7      # r4   r   r   	dirichlet)alphar6   s   &&r   numpy_dirichletrG   D   s    99u00r   c                 @    \         P                  P                  V 4      # r   rD   )rF   s   &r   numpy_dirichlet_defaultrI   G   s    99u%%r   c                 D    \         P                  P                  WVR 7      # r4   r   r   noncentral_chisquare)dfnoncr6   s   &&&r   numpy_noncentral_chisquarerO   J   s    99))")>>r   c                 @    \         P                  P                  W4      # r   rK   )rM   rN   s   &&r   "numpy_noncentral_chisquare_defaultrQ   M   s    99))"33r   c                    \         P                  P                  V 4       \         P                  P                  W34      p\         P                  P                  V 4       \         P                  P                  W4      pW43# r   )r   r   seedrandrS   r   r"   expectedgots   &&&  r   numpy_check_randrX   P   sR    IINN4yy'HIINN4
))..
C=r   c                    \         P                  P                  V 4       \         P                  P                  W34      p\         P                  P                  V 4       \         P                  P	                  W4      pW43# r   )r   r   rS   standard_normalrandnrU   s   &&&  r   numpy_check_randnr\   W   sR    IINN4yy((!0HIINN4
))//!
C=r   c                 r    R \        4       ,          p\        RV\        4       4      p\        RR7      ! V4      # )z@def func(%(argstring)s):
        return %(name)s(%(argstring)s)
funcTnopython)localsr	   globalsr   )name	argstringcodepyfuncs   &&  r   jit_with_argsrg   ^   s5    hD fdGI6Ff%%r   c                     R P                  V Uu. uF	  q" RV 2NK  	  up4      pR P                  V4      pRV RV  RV R2p\        RV\        4       4      p\        RR7      ! V4      # u upi )	,=z	def func(z):
        return (z)
r^   Tr_   )joinr	   rb   r   )rc   
kwarg_listkwcall_args_with_kwargs	signaturere   rf   s   &&     r   jit_with_kwargsrq   e   s    HHZ%HZrAbTlZ%HI$I $vQ,- .D fdGI6Ff%% &Is   A*c                     \        V R 4      # ) rg   rc   s   &r   jit_nullaryrv   o   s    r""r   c                     \        V R 4      # r   rt   ru   s   &r   	jit_unaryrx   r   s    s##r   c                     \        V R 4      # )za, brt   ru   s   &r   
jit_binaryrz   u   s    v&&r   c                     \        V R 4      # )za, b, crt   ru   s   &r   jit_ternaryr|   x   s    y))r   random.gausszrandom.randomzrandom.seednp.random.normalnp.random.randomnp.random.seedc                    V P                  4       ^,          pVRR VR,          rC\        P                  ! W\        V4      34       W43# )z7
Copy state of Python random *r* to Numba state *ptr*.
N)getstater   rnd_set_statelist)rptrmtintsindexs   &&   r   _copy_py_stater      sC     
aBSb'2b6%S$t*"56;r   c           
         V P                  4       R,          w  r#\        P                  ! YV Uu. uF  p\        V4      NK  	  up34       W#3# u upi )z6
Copy state of Numpy random *r* to Numba state *ptr*.
:      N)	get_stater   r   int)r   r   r   r   xs   &&   r   _copy_np_stater      sJ     ++-$KDS4*@4a3q64*@"AB; +As   Ac                    V P                  4       w  rpVR,          pVRR p\        V4      R8X  g   Q hR\        P                  ! VRR7      V3pVf   VR,          pMV^V3,          p\        P                  P                  V4       R# )r   Nr   MT19937uint32dtyper   )r           )r   lenr   arrayr   	set_state)r   _vermt_st_gauss_nextmt_posmt_intsnp_sts   &      r   sync_to_numpyr      s     zz|D2YFCRjGw<396BE![!!IIr   c                 B    R V P                  VR ,          R4      ,          #        @      ?)gammavariate)r   rM   s   &&r   py_chisquarer      s    S#...r   c                 T    \        W4      V,          \        W4      V,          ,          # r   )r   )r   numdenoms   &&&r   py_fr      s&    !!E)!#c)+ ,r   c                   4   a  ] tR t^t o RR ltRR ltRtV tR# )BaseTestc                H    \         P                  ! V4      p\        W14       V# r   )r   Randomr   selfr   rS   r   s   &&& r   _follow_cpythonBaseTest._follow_cpython   s    MM$qr   c                Z    \         P                  P                  V4      p\        W14       V# r   )r   r   RandomStater   r   s   &&& r   _follow_numpyBaseTest._follow_numpy   s#    II!!$'qr   r   N   )__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     
 r   r   c                   T   a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
tV tR# )TestInternalsz1
Test low-level internals of the implementation.
c                   \         P                  ! V4      pVw  r4V P                  V\        4       V P                  V\        4       V P                  \        V4      \        4       VR ,          \        ,          p\        \        4       Uu. uF  q3^,          NK  	  pp\         P                  ! WV34       V P                  \         P                  ! V4      WT34       R# u upi )i N)
r   rnd_get_stateassertIsInstancer   r   assertEqualr   Nranger   )r   r   stateir   js   &&    r   _check_get_set_state"TestInternals._check_get_set_state   s    ((-a%dD)TA&Z1$Qx(x!Ax(  $i011#6	B )s   Cc                   \         P                  ! 4       p\        W!4      w  r4\        V\        ^,           ^4       F  pVP                  4        K  	  \
        P                  ! V4       VP                  4       ^,          pVRR VR,          rCV P                  \
        P                  ! V4      ^,          \        V4      4       R# )r   Nr   )r   r   r   r   r   r   rnd_shuffler   r   r   r   )r   r   r   r   r   r   r   s   &&     r   _check_shuffleTestInternals._check_shuffle   s    MMO$Q,ua!eQ'AHHJ (s#ZZ\!_"gr"ve11#6q94:Fr   c                   \         P                  P                  4       pR F  pVP                  \         P                  ! V4      4       VP                  4       p\        V^,          4      pV^,          pV\        8X  g   Q h\        P                  ! W4       V P                  \        P                  ! V4      We34       K  	  R# )r   N)r   r   }   l    )r   r   r   rS   r   r   r   r   r   rnd_seedr   r   )r   r   r   r   str   r   s   &&     r   _check_initTestInternals._check_init   s     II!!#'AFF299Q< B1;DqEEA::'Z55c:UMJ (r   c                v   . p\        ^
4       Fz  p\        P                  ! V^ 4       \        P                  ! V\        P                  ! R4      4       VP                  \        \        P                  ! V4      ^,          4      4       K|  	  V P                  \        \        V4      4      \        V4      4       R# )
   i   N)r   r   r   osurandomappendtupler   r   r   set)r   r   statesr   s   &&  r   _check_perturbTestInternals._check_perturb   s}    rAQ'RZZ_5MM%
 8 8 =a @AB  	S[)3v;7r   c                8    V P                  \        4       4       R # r   )r   r   r   s   &r   test_get_set_state TestInternals.test_get_set_state   s    !!"2"45r   c                8    V P                  \        4       4       R # r   )r   r   r   s   &r   test_shuffleTestInternals.test_shuffle       ,./r   c                8    V P                  \        4       4       R # r   )r   r   r   s   &r   	test_initTestInternals.test_init   s    )+,r   c                8    V P                  \        4       4       R # r   )r   r   r   s   &r   test_perturbTestInternals.test_perturb   r   r   r   N)r   r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   r   s   @r   r   r      s:     
CGK	860-0 0r   r   c                     a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tRUR ltRUR ltR tR tR tR tR tR tR tR tR tRVR 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&R& t'R' t(R( t)R) t*R* t+R+ t,R, t-R- t.R. t/R/ t0R0 t1R1 t2R2 t3R3 t4R4 t5R5 t6R6 t7R7 t8R8 t9R9 t:R: t;R; t<R< t=R= t>R> t?R? t@R@ tARA tBRB tCRC tDRD tERE tFRF tGRG tHRH tIRI tJRJ tKRK tLRL tMRM tNRN tORO tPRP tQRQ tRRR tSRS tTRTtUV tVR
# )W
TestRandom   c           	     6   \         P                  P                  4       pR Ft  pVP                  \         P                  ! V4      4       V! V4       \        \        ^
,           4       F*  pV P                  V! 4       VP                  RR4      4       K,  	  Kv  	  R# )z,
Check seed()- and random()-like functions.
r   r   Nr   r   r   l    )	r   r   r   rS   r   r   r   assertPreciseEqualuniform)r   seedfunc
randomfuncr   r   r   s   &&&   r   _check_random_seedTestRandom._check_random_seed  sj    
 II!!#'AFF299Q< QK1r6]''
aiiS6IJ # (r   c                :    V P                  \        \        4       R # r   )r   random_seedrandom_randomr   s   &r   test_random_randomTestRandom.test_random_random  s    ];r   c                2   V P                  \        \        4       V P                  \        \        R 4      4       V P                  \        \        R4      4       V P                  \        \        R4      4       V P                  \        \        R4      4       R# np.random.random_samplenp.random.ranfnp.random.sampleznp.random.randN)r   
numpy_seednumpy_randomrv   r   s   &r   test_numpy_randomTestRandom.test_numpy_random  sj    
L9
K8Q,RS
K8H,IJ
K8J,KL
K8H,IJr   c           
     $   \         P                  P                  4       pR Fk  pVP                  \         P                  ! V4      4       V! V4       \        ^
4       F,  pV P                  V! V4      VP                  RRV4      4       K.  	  Km  	  R# )r   r   r   Nr   )r   r   r   rS   r   r   r   r   )r   r   r   r   r   r>   s   &&&   r   _check_random_sizedTestRandom._check_random_sized   sh    II!!#'AFF299Q< QK2Y''
1qyyc17MN 	 (r   c                    V P                  \        \        R 4      4       V P                  \        \        R4      4       V P                  \        \        R4      4       V P                  \        \        R4      4       R# r  )r  r  rx   r   s   &r   test_numpy_random_sized"TestRandom.test_numpy_random_sized*  sZ      Y7P-QR  Y7G-HI  Y7I-JK  Y7G-HIr   c                   ^
p\        ^4       \        V4       Uu. uF  p\        4       NK  	  pp\        ^4       \        V4       Uu. uF  p\	        4       NK  	  pp\        ^4       \        ^4       \        V4       Uu. uF  p\        4       \	        4       3NK  	  ppT P                  V Uu. uF  qf^ ,          NK  	  upV4       T P                  V Uu. uF  qf^,          NK  	  upV4       R# u upi u upi u upi u upi u upi )r   N)r   r   r   r  r	  r   )r   r   r   
py_numbers
np_numberspairsps   &      r   test_independent_generators&TestRandom.test_independent_generators0  s    A/4Qx8x!mox
81.3Ah7hlnh
7A1<A!HEHq-/<>2HEu 5u!1u 5zBu 5u!1u 5zB 97 F 5 5s   C1C6 C;.D Dc                ,   V P                  V4      p\        ^^A4       F-  pVP                  V4      pV! V4      pV P                  WV4       K/  	  V P	                  \
        V^A4       V P	                  \
        VR4       V P	                  \
        VR4       R# )z&
Check a getrandbits()-like function.
i Nr   )r   r   getrandbitsr   assertRaisesOverflowError)r   r^   r   r   nbitsrV   rW   s   &&&    r   _check_getrandbitsTestRandom._check_getrandbits=  s    
   %1b\E}}U+Hu+C##H2 " 	-r2-w7-r2r   c                L    V P                  \        R 4      \        4       4       R# )zrandom.getrandbitsN)r  rx   r   r   s   &r   test_random_getrandbits"TestRandom.test_random_getrandbitsK      	*> ?AQASTr   Nc           	        \        V4      '       g   Q hV Ff  p\        V4       U	u. uF  q! V!  NK
  	  p
p	\        V4       U	u. uF  p	V'       d	   V! VR V/ MV! V!  NK  	  pp	V P                  WWVRV: 2R7       Kh  	  R# u up	i u up	i )r   for arguments preculpsmsgNr   r   r   )r   r^   rf   argslistnitersr'  r(  pydtypeargsr   results	pyresultss   &&&&&&&&    r   _check_distTestRandom._check_distS  s    8}}}D,1&M:MqtT{MG:"'-1"/Q ;B&$6g6vt}T"/  1##GT>B(D $ F	 :1s   BBBc           
     (   \        V4      '       g   Q hV Fn  p\        V4       U	u. uF
  q! R/ VB NK  	  p
p	\        V4       U	u. uF  p	V'       d   V! R/ VBR V/B MV! R/ VB NK!  	  pp	V P                  WWVRV: 2R7       Kp  	  R# u up	i u up	i )r   r%  r&  Nr   r*  )r   r^   rf   
kwargslistr,  r'  r(  r-  kwargsr   r/  r0  s   &&&&&&&&    r   _check_dist_kwargsTestRandom._check_dist_kwargs]  s    : F/4V}=}!t~f~}G="'-1"/Q >E&9699&JZSYJZZ"/  1##GT>D(F $ H	 !=1s   B
BBc                   V P                  V4      pVe3   V P                  WP                  . RO\        ^,          ^
,           R7       Ve   V P                  W%P                  R.4       Ve    V P                  W5P                  R.4       R# R# )z 
Check a gauss()-like function.
Nr,  r   r   )r         ?)g       r<  r<  r   )r   r1  normalr   r   func2func1func0r   r   s   &&&&& r   _check_gaussTestRandom._check_gaussg  s    
 s#UHHB$%FRK  1 UHHvh7UHHrd3 r   c                P    V P                  \        R 4      RR\        4       4       R# )r}   NrC  rz   r   r   s   &r   test_random_gaussTestRandom.test_random_gaussv  s    *^4dDBRBTUr   c                P    V P                  \        R 4      RR\        4       4       R# )zrandom.normalvariateNrF  r   s   &r   test_random_normalvariate$TestRandom.test_random_normalvariatey  s$     	*%;<dD*,	.r   c                t    V P                  \        R 4      \        R 4      \        R 4      \	        4       4       R# )r~   N)rC  rz   rx   rv   r   r   s   &r   test_numpy_normalTestRandom.test_numpy_normal  s0    *%78#$67%&89*,	.r   c                P    V P                  R R \        R4      \        4       4       R # )Nnp.random.standard_normalrC  rv   r   r   s   &r   test_numpy_standard_normal%TestRandom.test_numpy_standard_normal  s"    $k2M&N*,	.r   c                P    V P                  R R \        R4      \        4       4       R # )Nznp.random.randnrQ  r   s   &r   test_numpy_randnTestRandom.test_numpy_randn  s"    $k2C&D*,	.r   c                   V P                  V4      pVe3   V P                  WP                  . RO\        ^,          ^
,           R7       Ve   V P                  W%P                  R.4       Ve    V P                  W5P                  R.4       R# R# )z)
Check a lognormvariate()-like function.
Nr9  r:  r=  r   )r   r1  	lognormalr   r?  s   &&&&& r   _check_lognormvariate TestRandom._check_lognormvariate  s    
 s#UKKB$%FRK  1 UKK&:UKK"6 r   c                P    V P                  \        R 4      RR\        4       4       R# )zrandom.lognormvariateN)rY  rz   r   r   s   &r   test_random_lognormvariate%TestRandom.test_random_lognormvariate  s$    "":.E#F#'/?/A	Cr   c                t    V P                  \        R 4      \        R 4      \        R 4      \	        4       4       R# )np.random.lognormalN)rY  rz   rx   rv   r   r   s   &r   test_numpy_lognormalTestRandom.test_numpy_lognormal  s0    "":.C#D#,-B#C#./D#E#3#5	7r   c           	        . p\        ^
4       FQ  p	VP                  V! R4      4       VP                  V! ^R4      4       Vf   K8  VP                  V! ^R^4      4       KS  	  V'       d   V P                  V4      P                  p
MV P	                  V4      P
                  p
R Uu. uF  qV8  g   K  VNK  	  ppV'       d   TMRpV F  pV P                  WV3.^
VR7       V P                  W*R^V,           3.^
VR7       Vf   K?  V P                  V! R^V,           ^4      V
! R^V,           ^4      4       V P                  V! ^V,           ^R4      V
! ^V,           ^R4      4       K  	  V P                  \        V^ 4       V P                  \        VR4       V P                  \        V^^4       V P                  \        V^^4       Ve5   V P                  \        V^^R4       V P                  \        V^^^4       R# R# u upi )	z$
Check a randrange()-like function.
 eN)r,  r-  )r           l                    r   )
r   r   r   r   r   r(   r1  r   r  
ValueError)r   rA  r@  func3r   	max_widthis_numpytpr   r   rrwwidthsr-  widths   &&&&&&&&       r   _check_randrangeTestRandom._check_randrange  s   
 rAKKi()KKa+, E!Y23	 
 ##C(00B%%c*44BBTB)m!!BT "dEU%
2$+  -U"ah(8$+  - ''b!e)Q(?(*2q5y!(<>''a%iB(?(*1u9a(<>  	*eQ/*eR0*eQ2*eQ2j%Ar:j%Aq9 # Us   &H3Hc           	         \         P                  R3\         P                  R33 Fe  w  r\        V34      ! \        4      p\        W34      ! \
        4      p\        WV34      ! \        4      pV P                  W4V\        4       VR4       Kg  	  R# )r   FN                    )	r   int64int32r   r)   r+   r.   rt  r   )r   ro  rm  cf1cf2cf3s   &     r   test_random_randrange TestRandom.test_random_randrange  sz    ${{E2U[[%4HIMBu+/0Cy"#45C}%&78C!!#C1A1C"+U4	 Jr   c           
     2   \         P                  \        P                  R3\         P                  \        P                  R33 FP  w  rp\	        V34      ! \
        4      p\	        W34      ! \        4      pV P                  WER\        4       VRV4       KR  	  R# )r   NTrw  rx  )	r   ry  r   rz  r   r   r#   rt  r   )r   ro  np_tprm  r{  r|  s   &     r   test_numpy_randintTestRandom.test_numpy_randint  sx    &+kk288U%C&+kk288U%C%E Byu+n-Cy/.1C!!#D2B2Di"&/	%Er   c                   . p\        ^
4       F  pVP                  V! ^R4      4       K  	  V P                  \        V4      \        \	        V4      4      V4       V P                  V4      pR F2  pV^,          V8  d   K  V P                  WP                  V.^
R7       K4  	  V P                  \        V^^4       V P                  \        V^^4       R# )z"
Check a randint()-like function.
rc  r9  N)r   rd  )   rf  )   rg  )
r   r   r   r   r   r   r1  r   r  rk  )r   r^   r   rm  r   r   r   r.  s   &&&&    r   _check_randintTestRandom._check_randint  s    
 rAKKQ	*+ TCD	ND9  %=DAw"T99tfR@ >
 	*dAq1*dAq1r   c                    \         P                  R3\         P                  R33 F6  w  r\        W34      ! \        4      pV P                  V\        4       V4       K8  	  R# )r   Nrw  rx  )r   ry  rz  r   r%   r  r   )r   ro  rm  cfs   &   r   test_random_randintTestRandom.test_random_randint  sL    ${{E2U[[%4HIMBri0B$4$6	B Jr   c                d    V P                  V4      pV P                  WP                  . RO4       R# )z"
Check a uniform()-like function.
N))      ?    .A)           @@)r  r  )r   r1  r   r   r^   r   r   s   &&& r   _check_uniformTestRandom._check_uniform  s,    
   %yy?	Ar   c                b    V P                  V4      p\        WS4      pV P                  WV4       R# )z
Check any numpy distribution function. Does Numba use the same keyword
argument names as Numpy?
And given a fixed seed, do they both return the same samples?
N)r   getattrr6  )r   r^   r   distrib	paramlistr   distrib_method_of_numpys   &&&&&  r   _check_any_distrib_kwargs$TestRandom._check_any_distrib_kwargs  s/     s#")!"5yIr   c                L    V P                  \        R 4      \        4       4       R# )zrandom.uniformN)r  rz   r   r   s   &r   test_random_uniformTestRandom.test_random_uniform  s    J'78:J:LMr   c                L    V P                  \        R 4      \        4       4       R# )np.random.uniformN)r  rz   r   r   s   &r   test_numpy_uniformTestRandom.test_numpy_uniform
  s    J':;=M=OPr   c                v    V P                  \        R RR.4      \        4       RRRRR/RR	RR/RRRR	/.R7       R# )
r  lowhighr   r  r  r  r  Nr  r  rq   r   r   s   &r   test_numpy_uniform_kwargs$TestRandom.test_numpy_uniform_kwargs  sV    &&/%AsFC0tVS1sFD13	 	' 	4r   c                    V P                  \        R . R
O4      \        4       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	7       R# )r  r  r  r6   r   r  r  r  Nr  )r  r  r6   r   r  r  r   s   &r   test_numpy_uniform_empty_size(TestRandom.test_numpy_uniform_empty_size  s    &&/1HIsFC<tVS&"=sFD&"=sFC>tVS&$?sFD&$?B	 	' 		Cr   c                    V P                  V4      pVe   V P                  WP                  . RO4       V P                  W$P                  R.4       R# )z%
Check a triangular()-like function.
N)r        @)r  r  )r  r  )r  r  皙@)r   r1  
triangular)r   r@  rl  r   r   s   &&&& r   _check_triangularTestRandom._check_triangular"  sI    
   %ULLBD.?@r   c                `    V P                  \        R 4      \        R 4      \        4       4       R# )zrandom.triangularN)r  rz   r|   r   r   s   &r   test_random_triangular!TestRandom.test_random_triangular-  s'    z*=>*+>?/1	3r   c                `   a \        R 4      oV3R lpV P                  RV\        4       4       R# )np.random.triangularc                    < S! WV4      # r   r   )lr   mr  s   &&&r   <lambda>2TestRandom.test_numpy_triangular.<locals>.<lambda>4  s    :aA+>r   N)r|   r  r   )r   fixed_triangularr  s   & @r   test_numpy_triangular TestRandom.test_numpy_triangular2  s+     !78
>t%57G7IJr   c                   V P                  V4      pVe   V P                  WP                  . RO4       Ve)   V P                  V! R4      VP                  RR4      4       Vea   V P	                  \
        VRR4       V P	                  \
        VRR4       V P	                  \
        VRR4       V P	                  \
        VRR4       Ve1   V P	                  \
        VR4       V P	                  \
        VR4       R# R# )z'
Check a gammavariate()-like function.
Nr   r  r   )r<        @)r   r  r        )r   r1  r   r   r  rk  )r   r@  rA  r   r   s   &&&& r   _check_gammavariateTestRandom._check_gammavariate7  s    
   %UNNAC##E#JsC0HIj%c:j%c:j%s;j%d;j%5j%6 r   c                N    V P                  \        R 4      R\        4       4       R# )zrandom.gammavariateN)r  rz   r   r   s   &r   test_random_gammavariate#TestRandom.test_random_gammavariateL  s       ,A!BD!1!3	5r   c                    V P                  \        R 4      \        R 4      \        4       4       V P                  R\        R4      \        4       4       R# )np.random.gammaNnp.random.standard_gamma)r  rz   rx   r   r   s   &r   test_numpy_gammaTestRandom.test_numpy_gammaP  sH      ,=!>!*+<!=!1!3	5 	  !*+E!F!1!3	5r   c                "   V P                  V4      pV P                  WP                  R.4       V P                  \        VRR4       V P                  \        VRR4       V P                  \        VRR4       V P                  \        VRR4       R# )z&
Check a betavariate()-like function.
r   r   Nr  r  )r   r1  betavariater  rk  r  s   &&& r   _check_betavariateTestRandom._check_betavariateX  sz    
   %}}zl;*dC5*dC5*dD#6*dC6r   c                L    V P                  \        R 4      \        4       4       R# )zrandom.betavariateN)r  rz   r   r   s   &r   test_random_betavariate"TestRandom.test_random_betavariatee  s    
+? @BRBTUr   c                L    V P                  \        R 4      \        4       4       R# )np.random.betaN)r  rz   r   r   s   &r   test_numpy_betaTestRandom.test_numpy_betah  s    
+; <>N>PQr   c                b    V P                  V4      pV P                  WP                  R.4       R# )z*
Check a vonmisesvariate()-like function.
Nr  )r   r1  vonmisesvariater  s   &&& r   _check_vonmisesvariate!TestRandom._check_vonmisesvariatek  s,       %00:,?r   c                L    V P                  \        R 4      \        4       4       R# )zrandom.vonmisesvariateN)r  rz   r   r   s   &r   test_random_vonmisesvariate&TestRandom.test_random_vonmisesvariater  s    ##J/G$H$4$6	8r   c                L    V P                  \        R 4      \        4       4       R# )np.random.vonmisesN)r  rz   r   r   s   &r   test_numpy_vonmisesTestRandom.test_numpy_vonmisesv  s    ##J/C$D$4$6	8r   c           	         V P                  V4      pR FE  p\        ^4       F3  pV P                  V! V4      VP                  ^V,          4      RR7       K5  	  KG  	  R# )zq
Check a expovariate()-like function.  Note the second argument
is inversed compared to np.random.exponential().
double)r'  N)g?r<  r  )r   r   r   exponential)r   r^   r   r   lambdr   s   &&&   r   _check_expovariateTestRandom._check_expovariatez  sW    
 s#$E1X''UQ]]1u95M-5 ( 7  %r   c                L    V P                  \        R 4      \        4       4       R# )zrandom.expovariateN)r  rx   r   r   s   &r   test_random_expovariate"TestRandom.test_random_expovariate  r#  r   c                    V P                  V4      pVe   V P                  WP                  . RO4       Ve    V P                  W$P                  R.4       R# R# )z&
Check a exponential()-like function.
N)r=  r   r  r   )r   r1  r  )r   rA  rB  r   r   s   &&&& r   _check_exponentialTestRandom._check_exponential  sP     s#UMM3KLUMMB48 r   c                `    V P                  \        R 4      \        R 4      \        4       4       R# )np.random.exponentialN)r  rx   rv   r   r   s   &r   test_numpy_exponential!TestRandom.test_numpy_exponential  s'    	*A B +,C D 0 2	4r   c                N    V P                  R \        R4      \        4       4       R # )Nnp.random.standard_exponential)r  rv   r   r   s   &r   test_numpy_standard_exponential*TestRandom.test_numpy_standard_exponential  s!     +,L M 0 2	4r   c                d    V P                  V4      pV P                  WP                  RR.4       R# )z(
Check a paretovariate()-like function.
Nr=  )r  )r   r1  paretovariater  s   &&& r   _check_paretovariateTestRandom._check_paretovariate  s-    
   %0@Ar   c                L    V P                  \        R 4      \        4       4       R# )zrandom.paretovariateN)r  rx   r   r   s   &r   test_random_paretovariate$TestRandom.test_random_paretovariate  s    !!),B"CEUEWXr   c                ^   a \        R 4      oV3R lpV P                  V\        4       4       R# )np.random.paretoc                 "   < S! V 4      R ,           # r  r   )r   paretos   &r   r  .TestRandom.test_numpy_pareto.<locals>.<lambda>  s    Sr   N)rx   r  r   )r   fixed_paretor  s   & @r   test_numpy_paretoTestRandom.test_numpy_pareto  s'    -.0!!,0@0BCr   c                    V P                  V4      pVe   V P                  WP                  R.4       Ve=   \        ^4       F+  pV P	                  V! R4      VP                  RR4      4       K-  	  R# R# )z)
Check a weibullvariate()-like function.
Nr  r   r  )r   r1  weibullvariater   r   )r   r@  rA  r   r   r   s   &&&&  r   _check_weibullvariate TestRandom._check_weibullvariate  sp    
   %U$4$4zlC1X''c
()(8(8c(BD  r   c                N    V P                  \        R 4      R\        4       4       R# )zrandom.weibullvariateN)r  rz   r   r   s   &r   test_random_weibullvariate%TestRandom.test_random_weibullvariate  s!    "":.E#F#')9);	=r   c                N    V P                  R \        R4      \        4       4       R # )Nnp.random.weibull)r  rx   r   r   s   &r   test_numpy_weibullTestRandom.test_numpy_weibull  s     ""43F)G#3#5	7r   c           	        \        R 4      pV P                  \        4       ^ 4      pV P                  WP                  R.4       R F  pV P                  V! VR4      ^ 4       V P                  V! VR4      V4       R F  pV! W44      pVR8  d   W2,
          p^V,
          pV P                  V^ 4       V P                  W#4       WC,          p^V,          \        P                  ! V4      ,          pV P                  W%V,
          WCV34       V P                  W%V,           WCV34       K  	  K  	  V P                  \        VR	R4       V P                  \        V^
R
4       V P                  \        V^
R4       R# )np.random.binomialr   r   r<  皙?N)   g      ?)d     '  )	g-C6?皙?皙?g9?r<  g㈵ ?皙??H.?r   皙)rz   r   r   r1  binomialr   assertGreaterEqualassertLessEqualmathsqrtr  rk  )r   r#  r   r>   r  rV   tols   &      r   test_numpy_binomialTestRandom.test_numpy_binomial  sE   23/115::
|<#AXa-q1Xa-q1PQNs7AAA''1-$$Q*5!ediil*''c>A!9E$$Q3q	B Q $ 	*hC8*hD9*hC8r   c                    \        R 4      pV P                  \        4       4      pV P                  V\        P
                  ! \        V4      RR.4       R# )np.random.chisquareNr  r  )rx   r   r   r1  	functoolspartialr   )r   	chisquarer   s   &  r   test_numpy_chisquareTestRandom.test_numpy_chisquare  sI    34	  !1!34"**<; &)	+r   c                    \        R 4      pV P                  \        4       4      pV P                  V\        P
                  ! \        V4      RR.4       R# )np.random.fNr<  r  )r  r  )rz   r   r   r1  r.  r/  r   )r   fr   s   &  r   test_numpy_fTestRandom.test_numpy_f  sG    }%  !1!34I--dA6$j1	3r   c                *   \        R 4      pV P                  \        VR
4       V P                  \        VR4       V P                  \        VR4       ^p\        V4       Uu. uF
  q1! R4      NK  	  ppV P	                  V^.V,          4       \        V4       Uu. uF
  q1! R4      NK  	  ppVP                  ^4      pV P                  WR^,          4       V P                  WR4       T P                  V Uu. uF  q3R8  g   K  VNK  	  up4       \        V4       Uu. uF
  q1! R4      NK  	  ppT P                  V Uu. uF  q3^8  g   K  VNK  	  up4       \        V4       Uu. uF
  q1! R4      NK  	  ppT P                  V Uu. uF  q3^28  g   K  VNK  	  up4       \        V4       Uu. uF
  q1! R4      NK  	  ppT P                  V Uu. uF  q3R8  g   K  VNK  	  up4       R	# u upi u upi u upi u upi u upi u upi u upi u upi u upi )np.random.geometricr   r   gjt?r   r  r  g{Gz?gV瞯<Ng              )
rx   r  rk  r   r   countr$  
assertLessassertFalse
assertTrue)r   geomr   r   r   r>   s   &     r   test_numpy_geometricTestRandom.test_numpy_geometric  s   ./*dD1*dC0*dE2 %a)1T#Y)A37+ %a)1T#Y)GGAJ6*Q3Qd(!!Q34 %a)1T#Y)A/AqQA/0!&q*AT$Z*A0AqRA01"'(+(QT%[(+A3AqUA34 *) 4)/*0+3sN    G(G-4G2G2G7<G<	G<#HHH+HHHc                    \        R 4      pV P                  \        4       4      pV P                  WP                  RR.4       R# )np.random.gumbelNr   r         r  )rz   r   r   r1  gumbel)r   rH  r   s   &  r   test_numpy_gumbelTestRandom.test_numpy_gumbel  s:    .//12J+DEr   c           
     l    V P                  \        R RR.4      \        4       RRRRR/RR	RR/.R7       R# )
rD  locscalerH  r   r   r  r  r  NrG  r  r   s   &r   test_numpy_gumbel_kwargs#TestRandom.test_numpy_gumbel_kwargs  sK    &&.0@AsGS1tWc24	 	' 	5r   c                :   \        R 4      pV P                  \        4       4      pV P                  WP                  RR.^R7       \        ^d4       Uu. uF  q1! RR^d4      NK  	  ppT P                  \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      V4       V P                  \        P                  ! V4      R4       V P                  \        P                  ! V4      R4       \        ^d4       Uu. uF  q1! RR^d4      NK  	  ppT P                  \        ;QJ d    R	 V 4       F  '       d   K   RM	  RM! R	 V 4       4      V4       V P                  \        P                  ! V4      R
4       \        ^d4       Uu. uF  q1! RR^d4      NK  	  ppT P                  \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      V4       V P                  \        P                  ! V4      R4       R# u upi u upi u upi )np.random.hypergeometricr  r9  c              3   D   "   T F  q^ 8  ;'       d    V^d8*  x  K  	  R# 5ir   Nr   .0r   s   & r   	<genexpr>7TestRandom.test_numpy_hypergeometric.<locals>.<genexpr>  !     ;AF//qCx/     FTg      D@g      N@順 c              3   D   "   T F  q^ 8  ;'       d    V^d8*  x  K  	  R# 5irT  r   rU  s   & r   rW  rX    rY  rZ        $@c              3   D   "   T F  q^ 8  ;'       d    V^d8*  x  K  	  R# 5irT  r   rU  s   & r   rW  rX    rY  rZ  g     V@Nr  rf  r   )rf  r  r   )r|   r   r   r1  hypergeometricr   r?  allr$  r   meanr%  )r   hgr   r   s   &   r   test_numpy_hypergeometric$TestRandom.test_numpy_hypergeometric  s   34/12--*,<= " 	 	$ +0*5*QRdC *5;;;;;Q?
D1RWWQZ.,1#J7JqRfc"J7;;;;;Q?RWWQZ.,1#J7JqRc"J7;;;;;Q?
D1 6 8 8s   HHHc                &   V P                  \        4       4      pV P                  \        R 4      VP                  RR.4       V P                  \        R 4      VP                  RR.4       V P                  \        R 4      VP                  R.4       R# )np.random.laplaceNrE  rF  r   rG  r   )r   r   r1  rz   laplacerx   rv   r   r   s   & r   test_numpy_laplaceTestRandom.test_numpy_laplace  s|    /12$78!))$k2	4#67 '*	,%89199rdKr   c                &   V P                  \        4       4      pV P                  \        R 4      VP                  RR.4       V P                  \        R 4      VP                  RR.4       V P                  \        R 4      VP                  R.4       R# )np.random.logisticNrE  rF  rh  ri  r   )r   r   r1  rz   logisticrx   rv   rk  s   & r   test_numpy_logisticTestRandom.test_numpy_logistic&  s|    /12$891::$k2	4#78!** '*	,%9:AJJMr   c                   V P                  \        4       4      p\        R 4      pV P                  W!P                  . RO^2R7       V P                  \        4       ^R7      pT P                  \        ^
4       Uu. uF
  q2! R4      NK  	  up. RO4       V P                  \        VR4       V P                  \        VR	4       V P                  \        VR4       R# u upi )
np.random.logseriesr9  rS   g{?r   r  N)r  )gGz?)r!  )
ivxi-    i  in i)l   &ci܀oirH i  r"  )	r   r   rx   r1  	logseriesr   r   r  rk  )r   r   rx  r   s   &   r   test_numpy_logseriesTestRandom.test_numpy_logseries.  s    /1234	KK5 " 	 	$
 /1:eBiHi)O4iHC	D 	*i5*i6*i5 Is   8Cc                    V P                  \        4       4      p\        R 4      pV P                  W!P                  . RO^2R7       V P                  \        VR4       R# )np.random.poissonr9  N)rh  r=  r   )r]  )g     $@r"  )r   r   rx   r1  poissonr  rk  )r   r   r~  s   &  r   test_numpy_poissonTestRandom.test_numpy_poisson>  sT    /12/0))D " 	 	$ 	*gt4r   c           	        V P                  \        4       ^ 4       \        R4      pT P                  \	        ^
4       Uu. uF  q!! ^
R4      NK  	  up. R
O4       T P                  \	        ^
4       Uu. uF  q!! ^
R4      NK  	  up. RO4       T P                  \	        ^
4       Uu. uF  q!! RR4      NK  	  up. RO4       T P                  \	        ^
4       Uu. uF  q!! RR4      NK  	  up. RO4       \
        P                  ! \	        ^24       Uu. uF  pV! RR4      NK  	  up4      pV P                  VR4       V P                  VR4       V P                  \        V^ R4       V P                  \        VRR4       V P                  \        V^
R4       V P                  \        V^
R4       R	# u upi u upi u upi u upi u upi )r   np.random.negative_binomialr   r  r  333333?i ʚ;r<  r  N)
r   r   r   rd  r   r   r   r   r   r   )
7   G   8   9   r  r  "   r  e   C   )
i#  i!  iy#  iL$  i"  i#  i#  iF"  i"  i#  )
r   r         r  r   r   r   r   r   g   | Bg   $s Br   r"  )r   r   rz   r   r   r   rb  assertGreaterr=  r  rk  )r   negbinr   r  s   &   r   test_numpy_negative_binomial'TestRandom.test_numpy_negative_binomialG  s   +-q19:59=9a&S/9=7	959=9a&S/9=B	DU2Y?Y&s+Y?8	9 	E"I>Iq&c*I>8	:GG#Bi)' J,') *1j):&*fa5*fb#6*fb$7*fb#6! >=? ?)s   F.1F3$F8F=Gc                    V P                  \        4       4      p\        R 4      pV P                  W!P                  . RO4       V P                  \        VR4       V P                  \        VR4       R# )np.random.powerr   N)rv  r=  )r   )g      @r"  )r   r   rx   r1  powerr  rk  )r   r   r  s   &  r   test_numpy_powerTestRandom.test_numpy_power\  s\    /12+,9	;*eS1*eT2r   c                6   V P                  \        4       4      p\        R 4      p\        R 4      pV P	                  W!P
                  . RO4       V P	                  W1P
                  R.4       V P                  \        VR4       V P                  \        VR4       R# )np.random.rayleighr   N)rv  r  )g      9@)r  r   r"  )r   r   rx   rv   r1  rayleighr  rk  )r   r   	rayleigh1	rayleigh0s   &   r   test_numpy_rayleighTestRandom.test_numpy_rayleighd  s}    /1223	 45	JJ9	;JJ5*i5*i6r   c                    V P                  \        4       4      p\        R 4      pV P                  W!P                  R.4       R# )np.random.standard_cauchyNr   )r   r   rv   r1  standard_cauchy)r   r   cauchys   &  r   test_numpy_standard_cauchy%TestRandom.test_numpy_standard_cauchyn  s9    /1289!2!2RD9r   c                    V P                  \        4       4      p\        R 4      p\        P                  ! \        R4       Uu. uF
  q2! ^4      NK  	  up4      pV P                  \        V4      R4       R# u upi )np.random.standard_trf  r<  N)r   r   rx   r   rb  r   r=  abs)r   r   
standard_tr   avgs   &    r   test_numpy_standard_t TestRandom.test_numpy_standard_ts  s_       !1!3456
ggeDk:kz!}k:;C#& ;s   A6c                J   V P                  \        4       4      p\        R 4      pV P                  W!P                  RR.4       V P                  \        VRR4       V P                  \        VRR4       V P                  \        VRR4       V P                  \        VRR4       R# )np.random.waldr   r   Nr;  )r         @r"  )r   r   rz   r1  waldr  rk  )r   r   r  s   &  r   test_numpy_waldTestRandom.test_numpy_wald}  s    /12*+vv
J'?@*dC5*dD#6*dC5*dC6r   c           
     0   \        R RR.4      pV P                  V\        4       RRRRR/RRRR/.R7       V P                  \        VRR4       V P                  \        VR
R4       V P                  \        VRR4       V P                  \        VRR
4       R	# )r  rb  rM  r  r   r   r  rN  r   Nr"  )rq   r  r   r  rk  )r   numba_versions   & r   test_numpy_wald_kwargs!TestRandom.test_numpy_wald_kwargs  s    '(867:KL&&}'7'9/53932M3932M2O 	' 	P
 	*mS#>*mT3?*mS#>*mS$?r   c                    V P                  \        4       4      p\        R 4      pV P                  W!P                  RR.^dR7       R F  pV P                  \        W#4       K  	  R# )np.random.zipfr9  Nr  r-  )r   r<  r   r"  )r   r   rx   r1  zipfr  rk  )r   r   r  vals   &   r   test_numpy_zipfTestRandom.test_numpy_zipf  sY    /12)*vv'7D(Cj$4 )r   c                T   \         P                  ! ^4      \         P                  ! ^ 4      P                  R4      .pV'       d   V P                  V4      pMV P	                  V4      pV F  p\        ^4       Fq  pVP                  4       pVP                  4       p	V! V4       V'       g   \        VP                  4      ^8X  g   KO  VP                  V	4       V P                  W4       Ks  	  K  	  V^ ,          pVP                  4       p
V! \        V
4      4       V P                  \        V4      \        V
4      4       V P                  \        V4      \        V
4      4       V P!                  4       ;_uu_ 4        V! \        R4      4       RRR4       R#   + '       g   i     R# ; i)z-
Check a shuffle()-like function for arrays.
s   xyzN)re  r  )r   arangereshaper   r   r   copyr   shapeshuffler   
memoryviewassertNotEqualr   r   sortedassertTypingError)r   r^   r   rn  arrsr   r   r   rW   rV   r"   s   &&&&       r   r   TestRandom._check_shuffle  s*    		"ryy}44V<=""3'A$$S)AA1Xffh668S	s177|q0IIh'++C:   GFFHZ]DGT!W-F1I.##%%F#$ &%%%s   :FF'	c                N    V P                  \        R 4      \        4       R4       R# )zrandom.shuffleFN)r   rx   r   r   s   &r   test_random_shuffleTestRandom.test_random_shuffle  s    I&679I9KUSr   c                N    V P                  \        R 4      \        4       R4       R# )znp.random.shuffleTN)r   rx   r   r   s   &r   test_numpy_shuffleTestRandom.test_numpy_shuffle  s    I&9:<L<NPTUr   c                   R\        4       ,          p\        4       p\        ^4       F  p\        P                  ! \
        P                  RV.\        P                  \        P                  R7      pVP                  4       w  rxVP                  ^ 8w  d-   \        RVP                  : RVP                  4       : R24      hVP                  \        VP                  4       4      4       K  	  V P                  \!        V4      ^V4       R# )z9
Check that the state is properly randomized at startup.
zif 1:
            from numba.tests import test_random
            func = getattr(test_random, %(func_name)r)
            print(func(*%(func_args)r))
            z-c)stdoutstderrzprocess failed with code z: stderr follows

N)ra   r   r   
subprocessPopensys
executablePIPEcommunicate
returncodeAssertionErrordecodeaddfloatstripr   r   )	r   	func_name	func_argsre   numbersr   popenouterrs	   &&&      r   _check_startup_randomness$TestRandom._check_startup_randomness  s     8	
 %qA$$cnndD%A,6OOJOOUE((*HC1$$(-(8(8#**,&H I IKKciik*+  	Wq'2r   c                *    V P                  R R4       R# )r   Nr   r  r   s   &r   test_random_random_startup%TestRandom.test_random_random_startup  s    &&;r   c                *    V P                  R R4       R# )random_gaussNr;  r  r   s   &r   test_random_gauss_startup$TestRandom.test_random_gauss_startup      &&~zBr   c                *    V P                  R R4       R# )r	  Nr   r  r   s   &r   test_numpy_random_startup$TestRandom.test_numpy_random_startup  s    &&~r:r   c                *    V P                  R R4       R# )numpy_normalNr;  r  r   s   &r   test_numpy_gauss_startup#TestRandom.test_numpy_gauss_startup  r  r   c                   \        R 4      pV P                  \        4       4      pR F  p\        P                  ! V4      pVP                  4       pV P                  V! V4      VP                  V4      4       V P                  V! V4      VP                  V4      4       V P                  WE4       K  	  \        P                  ! ^
4      P                  ^^4      \        P                  ! ^4      P                  ^^^4      \        P                  ! ^$4      P                  ^^^^4      .pV FK  pVP                  4       pV P                  V! V4      VP                  V4      4       V P                  WE4       KM  	  R# )znp.random.permutationN)rd  r   r  r  )	rx   r   r   r   r  r  r   permutationr  )r   r^   r   sr   r"   r  s   &      r   test_numpy_random_permutation(TestRandom.test_numpy_random_permutation  s$   01/12 A		!AA##DGQ]]1-=>##DGQ]]1-=>##A) ! 		"%%a+		"%%aA.		"%%aAq13 AA##DGQ]]1-=>##A) r   r   )r   r     Nr   )Wr   r   r   r   r   r  r
  r  r  r  r  r!  r1  r6  rC  rG  rJ  rM  rR  rU  rY  r\  r`  rt  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)  r1  r7  rA  rI  rO  rd  rl  rq  ry  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r   r   r   s   @r   r   r      s    K<KOJC3UFH4V....7C7":H4/2&C
A	JNQ4
C	A3
K
7*557VR@88	7U94
4
BYD
D=792+35,F
52&LN6 57*37:
'7
@5%6TV3(<C;C* *r   r   c                      a  ] tR tRt o 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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!R  t"R! t#R" t$R# t%R$ t&R% t'R&t(V t)R'# )(TestRandomArraysi  z9
Test array-producing variants of np.random.* functions.
c                L    R V: 2pRP                  RRV 4      p\        W44      # )
np.random., abcdN)rl   rg   )r   funcnamenargsqualnamerd   s   &&&  r   _compile_array_dist$TestRandomArrays._compile_array_dist  s)    %-/IIfVen-	X11r   c                   V P                  V\        V4      ^,           4      pV P                  \        4       4      p\	        WA4      pR F  pW&3,           pV! V!  pV! V!  p	VP
                  \        P
                  ! R4      8X  dA   V	P
                  \        P
                  ! R4      8X  d   VP                  V	P
                  4      pV P                  WR^R7       K  	  VR,           pV! V!  pV! V!  p	V P                  WR^R7       R# )z=
Check returning an array according to a given distribution.
rz  ry  r  r'  r(  Nre  r   r   r   )	r  r   r   r   r  r   r   astyper   )
r   r  scalar_argscfuncr   rf   r6   r.  rV   rW   s
   &&&       r   _check_array_dist"TestRandomArrays._check_array_dist  s     ((3{3Ca3GH/12%D(Dt}H,C"((7"33II'!22#??3995##Hq#I   W$4=TlH1Er   c                  aa V P                  V\        V4      ^,           4      pV P                  \        4       4      p\	        VR4      oW#,           oVV3R lpVR,           pV! 4       pV! V!  p	V P                  WR^R7       R Fm  p
W*3,           p\        P                  ! V
4      pVP                  p\        VP                  4       F  pV! 4       W&   K  	  V! V!  p	V P                  WR^R7       Ko  	  R# )z~
Check returning an array according to a given gamma distribution,
where we use CPython's implementation rather than NumPy's.
r   c                     < S! S!  # r   r   )_argsrf   pyfunc_argss   *r   r  :TestRandomArrays._check_array_dist_gamma.<locals>.<lambda>  s
    &+"6r   Nr  r  r   r  )r  r   r   r   r  r   r   emptyflatr   r6   )r   r  r  extra_pyfunc_argsr  r   pyrandomr.  rV   rW   r6   expected_flatidxrf   r  s   &&&&         @@r   _check_array_dist_gamma(TestRandomArrays._check_array_dist_gamma  s    
 ((3{3Ca3GH  !1!34N+!56W$:TlH1ED(Dxx~H$MMMX]]+%-Z" ,,C##Hq#I  r   c                V   \         P                  R 4       pV P                  V\        V4      ^,           4      pRV: 2pRP	                  RR\        V4       4      p\        WV4      pR	 F  pW(3,           p	V! 4        V! V	!  p
V! 4        \        P                  ! WP                  R7      pVP                  p\        VP                  4       F  pV! V!  W&   K  	  V P                  WR^R7       K  	  V! 4        VR
,           p	V! V!  pV! 4        V! V	!  p
V P                  WR^R7       R# )a  
Check function returning an array against its scalar implementation.
Because we use the CPython gamma distribution rather than the NumPy one,
distributions which use the gamma distribution vary in ways that are
difficult to compare. Instead, we compile both the array and scalar
versions and check that the array is filled with the same values as
we would expect from the scalar version.
c                  D    \         P                  P                  R 4       R# )i  N)r   r   rS   r   r   r   reset6TestRandomArrays._check_array_dist_self.<locals>.reset0  s    IINN4 r   r  r  r   Nr   r  r  r  r   )numbar   r  r   rl   rg   r   r  r   r  r   r6   r   )r   r  r  r  
array_funcr  rd   scalar_funcr6   r.  rW   rV   r  r  s   &&&           r   _check_array_dist_self'TestRandomArrays._check_array_dist_self'  s    
	! 
	! --hK8H18LM
%-/IIf%6c+&678	#H8D(DGd#CG xxII6H==DX]]+'5	 ,##Hq#I   	W$,$H1Er   c                   V P                  R ^4      pRRr2RpV! W#V4      pV P                  V\        P                  4       V P	                  VP
                  V4       V P                  VP                  \        P                  ! R4      \        P                  ! R4      34       V P                  \        P                  ! WR8  4      4       V P                  \        P                  ! WS8  4      4       W#,           ^,          pW2,
          ^,          pV P                  VP                  4       Wg,
          4       V P                  VP                  4       Wg,           4       R# )r   r  r  rz  ry  Nrw  rw  )r  r   r   ndarrayr   r  assertInr   r?  ra  r$  rb  r%  )r   r  r  r  r6   resrb  r(  s   &       r   r  #TestRandomArrays.test_numpy_randintN  s    ((A6%TCt$c2::.D)cii"((7"3RXXg5F!GHsz*+sz*+
azR
DJ7SXXZ4r   c                   V P                  R ^4      pR	pV! V4      pV P                  V\        P                  4       V P	                  VP
                  V4       V P	                  VP                  \        P                  ! R4      4       V P                  \        P                  ! VR8  4      4       V P                  \        P                  ! VR8  4      4       V P                  \        P                  ! VR8*  4      4       V P                  \        P                  ! VR8  4      4       VP                  4       pV P                  VR4       V P                  VR4       R# )
r   float64r   r   r  r   g?g?Nr&  )r  r   r   r'  r   r  r   r?  ra  anyrb  r$  r%  )r   r  r6   r)  rb  s   &    r   test_numpy_random_random)TestRandomArrays.test_numpy_random_random^  s    ((15Dkc2::.D)BHHY$78scz*+sSy)*scz*+scz*+xxzd+T4(r   c                *    V P                  R R4       R# )betaNr  r#  r   s   &r   r   TestRandomArrays.test_numpy_betar  s    ##FJ7r   c                *    V P                  R R4       R# )r#  N)r  r<  r  r   s   &r   r)  $TestRandomArrays.test_numpy_binomialu  s    z95r   c                *    V P                  R R4       R# )r0  Nr  r2  r   s   &r   r1  %TestRandomArrays.test_numpy_chisquarex  s    ##K8r   c                *    V P                  R R4       R# )r  Nr  r5  r   s   &r   r  'TestRandomArrays.test_numpy_exponential{  s    }f5r   c                *    V P                  R R4       R# )r6  Nr5  r2  r   s   &r   r7  TestRandomArrays.test_numpy_f~  s    ##C4r   c                ,    V P                  R RR4       R# )gammaNr   r   r  r   s   &r   r  !TestRandomArrays.test_numpy_gamma  s    $$Wj"=r   c                *    V P                  R R4       R# )	geometricNr  r5  r   s   &r   rA  %TestRandomArrays.test_numpy_geometric      {F3r   c                *    V P                  R R4       R# )rH  Nr  r<  r5  r   s   &r   rI  "TestRandomArrays.test_numpy_gumbel      x4r   c                *    V P                  R R4       R# )r`  Nr_  r5  r   s   &r   rd  *TestRandomArrays.test_numpy_hypergeometric  s    /1ABr   c                *    V P                  R R4       R# )rj  NrF  r5  r   s   &r   rl  #TestRandomArrays.test_numpy_laplace      y*5r   c                *    V P                  R R4       R# )rp  NrF  r5  r   s   &r   rq  $TestRandomArrays.test_numpy_logistic  s    z:6r   c                *    V P                  R R4       R# )rX  N)r  r   r5  r   s   &r   r`  %TestRandomArrays.test_numpy_lognormal  s    {J7r   c                *    V P                  R R4       R# )rx  Nr  r5  r   s   &r   ry  %TestRandomArrays.test_numpy_logseries  rD  r   c                *    V P                  R R4       R# )r>  N)r<  r   r5  r   s   &r   rM  "TestRandomArrays.test_numpy_normal  rH  r   c                *    V P                  R R4       R# )r  Nr=  r5  r   s   &r   r	  "TestRandomArrays.test_numpy_pareto  s    x0r   c                *    V P                  R R4       R# )r~  Nr  r5  r   s   &r   r  #TestRandomArrays.test_numpy_poisson  s    y&1r   c                *    V P                  R R4       R# )r  Nr  r5  r   s   &r   r  !TestRandomArrays.test_numpy_power  s    w/r   c                    \        R R7      ! \        4      pV! ^*^^4      w  r#V P                  VP                  R4       V P	                  W#4       R# Tr_   Nr	  )r   rX   r   r  r   r   r  rV   rW   s   &   r   test_numpy_rand TestRandomArrays.test_numpy_rand  sC    T"#34b!QF+.r   c                    \        R R7      ! \        4      pV! ^*^^4      w  r#V P                  VP                  R4       V P	                  W#4       R# r]  )r   r\   r   r  r   r^  s   &   r   rU  !TestRandomArrays.test_numpy_randn  sC    T"#45b!QF+.r   c                *    V P                  R R4       R# )r  Nr  r5  r   s   &r   r  $TestRandomArrays.test_numpy_rayleigh  s    z62r   c                *    V P                  R R4       R# )r  Nr   r5  r   s   &r   r  +TestRandomArrays.test_numpy_standard_cauchy      0"5r   c                *    V P                  R R4       R# )standard_exponentialNr   r5  r   s   &r   r  0TestRandomArrays.test_numpy_standard_exponential  s    5r:r   c                ,    V P                  R RR4       R# )standard_gammaNr}  r  r?  r   s   &r   test_numpy_standard_gamma*TestRandomArrays.test_numpy_standard_gamma  s    $$%5vvFr   c                *    V P                  R R4       R# )rZ   Nr   r5  r   s   &r   rR  +TestRandomArrays.test_numpy_standard_normal  rg  r   c                *    V P                  R R4       R# )r  N)r  r  r  r5  r   s   &r   r  &TestRandomArrays.test_numpy_triangular  s    |_=r   c                *    V P                  R R4       R# )r   Nr  r  r5  r   s   &r   r  #TestRandomArrays.test_numpy_uniform  rM  r   c                *    V P                  R R4       R# )r  Nrt  r5  r   s   &r   r   TestRandomArrays.test_numpy_wald  s    vz2r   c                *    V P                  R R4       R# )vonmisesNr  r2  r   s   &r   r  $TestRandomArrays.test_numpy_vonmises  s    ##J
;r   c                *    V P                  R R4       R# )r  Nr-  r5  r   s   &r   r   TestRandomArrays.test_numpy_zipf  s    vv.r   r   N)*r   r   r   r   r   r  r  r  r#  r  r.  r  r)  r1  r  r7  r  rA  rI  rd  rl  rq  r`  ry  rM  r	  r  r  r_  rU  r  r  r  rm  rR  r  r  r  r  r  r   r   r   s   @r   r  r    s     2
F*J0%FN5 )(86965>45C67845120//36;G6>63</ /r   r  c                      a  ] tR tRt o RtRR ltR tR tR tR t	R t
RR	 ltR
 tR tR tR tR tR tR tRtV tR# )TestRandomChoicei  z
Test np.random.choice.
c                D   \        V4      p\        V4      pV P                  WT4       V P                  \        V4      \	        V4      4       V'       d(   V P                  \        V4      \        V4      V4       R# V P                  \        V4      \        V4      V4       R# )z4
Check basic expectations about a batch of samples.
N)r   r%  r  r  r   r=  r   r   )r   popr)  r9   spopsress   &&&&  r   _check_resultsTestRandomChoice._check_results  ss     3x3xT(F3Kc3OOCIs3x5 SYC#6r   c                @   V P                  \        V4      \        V4      ^d,          4       \        V4      \        V4      ,          p\        P                  ! V4      pV F;  pWE,          pV P                  WcR,          4       V P	                  WcR,          4       K=  	  R# )%
Check distribution of some samples.
r<  r   N)r$  r   collectionsCounterr%  )r   r  samplesexpected_frequencyr-   valuer>   s   &&&    r   r1  TestRandomChoice._check_dist  sz    
 	Gc#hn= \CH4(EA##AC'?@  $<= r   c                v    . p\        V4      V8  d$   V\        V! 4       P                  4      ,          pK3  VRV # )zS
Accumulate array results produced by *func* until they reach
*nresults* elements.
N)r   r   r  )r   r^   nresultsr)  s   &&& r   _accumulate_array_results*TestRandomChoice._accumulate_array_results  s6    
 #h!4$$C9H~r   c                *   \        RR7      ! \        4      p\        V4      p\        V4       Uu. uF
  qS! V4      NK  	  ppV P	                  W&4       \        V^d,          4       Uu. uF
  qS! V4      NK  	  ppV P                  W'4       R# u upi u upi )z
Check choice(a) against pop.
Tr_   N)r   r2   r   r   r  r1  )r   r   r  r  r>   r   r)  dists   &&&     r   _check_choice_1 TestRandomChoice._check_choice_1  s|     T"=1H!&q*AuQx*C%"'C.1.Qa.1# +1s   B&Bc                T    ^2p\        \        V4      4      pV P                  W4       R# )z
Test choice(int)
N)r   r   r  r   r>   r  s   &  r   test_choice_scalar_1%TestRandomChoice.test_choice_scalar_1	  s$     58nQ$r   c                p    \         P                  ! ^24      ^,          ^d,           pV P                  W4       R# )z
Test choice(array)
N)r   r  r  r   r  s   & r   test_choice_array_1$TestRandomChoice.test_choice_array_1  )     iima#%S&r   c                    \        V4      p\        V! 4       P                  4      pV P                  W%V4       V P	                  W^d,          4      pV P                  W&4       R# )z@
Check array results produced by *func* and their distribution.
N)r   r   r  r  r  r1  )r   r^   r  r9   r>   r)  r  s   &&&&   r   _check_array_results%TestRandomChoice._check_array_results  sO     H46;;Cg.--dG<#r   c                V  aaa \        RR7      ! \        4      o\        V4      pV^
,
          ^V^,
          ^,          3V^
,          .pV F[  oS! SS4      p\        S\        4      '       d   SMS3pV P                  VP                  V4       V P                  VVV3R lV4       K]  	  R# )z$
Check choice(a, size) against pop.
Tr_   c                     < S! S S4      # r   r   r   r  r6   s   r   r  2TestRandomChoice._check_choice_2.<locals>.<lambda>2  s    eAtnr   N)r   r7   r   
isinstancer   r   r  r  )	r   r   r  r>   sizesr)  expected_shaper  r6   s	   &f&    @@r   _check_choice_2 TestRandomChoice._check_choice_2"  s     T"=1H R!a!e\*AF3D4.C%/e%<%<T4'NSYY7%%&<cB r   c                X    ^2p\         P                  ! V4      pV P                  W4       R# )z
Test choice(int, size)
Nr   r  r  r  s   &  r   test_choice_scalar_2%TestRandomChoice.test_choice_scalar_24  $     iilQ$r   c                p    \         P                  ! ^24      ^,          ^d,           pV P                  W4       R# )z
Test choice(array, size)
Nr  r  s   & r   test_choice_array_2$TestRandomChoice.test_choice_array_2<  r  r   c                  aa	a
 \        RR7      ! \        4      o	\        V4      pV^
,
          ^V^,
          ^,          3.pRR.pV FM  o
R FD  pS	! SS
V4      p\        S
\        4      '       d   S
MS
3pV P                  VP                  V4       KF  	  KO  	  V F  o
V P                  VV	V
3R lV4       K  	  V F  o
V P                  VV	V
3R lVR4       K  	  V^,           ^V^,          ^,           33 F3  o
V P                  \        4      ;_uu_ 4        S	! SS
R4       RRR4       K5  	  R#   + '       g   i     KJ  ; i)z-
Check choice(a, size, replace) against pop.
Tr_   Fc                     < S! S SR 4      # Tr   r  s   r   r  2TestRandomChoice._check_choice_3.<locals>.<lambda>W  s    eAtT.Br   c                     < S! S SR 4      # )Fr   r  s   r   r  r  Z  s    eAtU.Cr   N)TF)
r   r:   r   r  r   r   r  r  r  rk  )r   r   r  r>   r  replacesr9   r)  r  r  r6   s   &f&      @@r   _check_choice_3 TestRandomChoice._check_choice_3C  s    T"=1H R!a!e\*+%= D(AtW-)3D%)@)@tg  N; )  D%%&BCH  D%%&CS%P  UQQ
O,D"":..au% /. -...s   D..D?c                X    ^2p\         P                  ! V4      pV P                  W4       R# )z!
Test choice(int, size, replace)
Nr   r  r  r  s   &  r   test_choice_scalar_3%TestRandomChoice.test_choice_scalar_3a  r  r   c                p    \         P                  ! ^24      ^,          ^d,           pV P                  W4       R# )z#
Test choice(array, size, replace)
Nr  r  s   & r   test_choice_array_3$TestRandomChoice.test_choice_array_3i  r  r   c                   \        R R7      R 4       p\        P                  P                  RRR7      P	                  \        P
                  4      pVP                  4       pVP                  ^V4      pVP                  4       pV! ^V4      p\        P                  P                  WF4       \        P                  P                  W#4       \        P                  P                  W%4       R# )Tr_   c                     \         P                  P                  R 4       \         P                  ! V ^3\         P                  4      p\        V 4       F&  p\         P                  P                  V^R4      W#&   K(  	  V# )i9  F)r   r   rS   r  rz  r   r1   )n_to_returnchoice_arrayr  r   s   &&  r   numba_rands>TestRandomChoice.test_choice_follows_seed.<locals>.numba_randss  sY    IINN4 ((K+RXX6C;')),5A (Jr   i,  r  r5   N)
r   r   r   r   r
  rz  r  py_functestingassert_allclose)r   r  r  tmp_nprV   tmp_nbrW   s   &      r   test_choice_follows_seed)TestRandomChoice.test_choice_follows_seedp  s     
d		 
	 yy((4(8??I""$&&q&1""$!V$


""81


""<8


""<8r   r   Nr  )r   r   r   r   r   r  r1  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   s   @r   r~  r~    sV     7">	$%'$C$%'&<%'9 9r   r~  c                      a  ] tR tRt o Rt]P                  ! . R
O]P                  R7      t]]P                  4       ,          tR t
R tR tR tRtV tR	# )TestRandomMultinomiali  z
Test np.random.multinomial.
r   c                P   V P                  V\        P                  4       V P                  VP                  \        V4      34       V P                  VP                  \        P                  ! R4      \        P                  ! R4      34       V P                  VP                  4       V4       \        W#4       Fj  w  rEV P                  V^ 4       V P                  WQ4       \        V4      V,          pV P                  WdR,          4       V P                  WdR,          4       Kl  	  R# )r  rz  ry  r<  r   N)r   r   r'  r   r  r   r(  r   sumzipr$  r%  r  )r   r>   r?   sampler  nexppexps   &&&&   r   _check_sample#TestRandomMultinomial._check_sample  s     	fbjj1E
}5fllRXXg%68I$JKq)5)GA##D!,  );?D##Dc'2  3w/ *r   c                   \        RR7      ! \        4      pRV P                  r2V! W#4      pV P                  W#V4       \	        V4      pV! W#4      pV P                  W#V4       Rp\
        P                  ! ^^ V^d,          ^.\
        P                  R7      pW3P                  4       ,          pV! W#4      pV P                  W#V4       R# )z
Test multinomial(n, pvals)
Tr_   r  i@B r   N)	r   r@   r?   r  r   r   r   r,  r  )r   r  r>   r?   r)  s   &    r   test_multinomial_2(TestRandomMultinomial.test_multinomial_2  s     T"#565Ao1S)UAo1S)!QS!,BJJ?Ao1S)r   c                    \        RR7      ! \        4      pRV P                  r2^
pV! W#V4      pV P                  VP                  ^ ,          V4       V F  pV P                  W#V4       K  	  R# )z'
Test multinomial(n, pvals, size: int)
Tr_   r  N)r   rB   r?   r   r  r  r   r  r>   r?   kr)  r  s   &      r   test_multinomial_3_int,TestRandomMultinomial.test_multinomial_3_int  sb     T"#565Aa 1q)Fq0 r   c                   \        RR7      ! \        4      pRV P                  r2RpV! W#V4      pV P                  VP                  RR V4       VP                  RVP                  R,          34       F  pV P                  W#V4       K  	  R# )z)
Test multinomial(n, pvals, size: tuple)
Tr_   r  N)r   r  r   )r   rB   r?   r   r  r  r  r  s   &      r   test_multinomial_3_tuple.TestRandomMultinomial.test_multinomial_3_tuple  sz     T"#565Aa 3B+kk2syy}"56Fq0 7r   r   N)r   r   r   r   r   r   )r   r   r   r   r   r   r   r,  r?   r  r  r  r  r  r   r   r   s   @r   r  r    sJ      HH'rzz:E	UYY[E0 *&
1
1 
1r   r  c                   x   a  ] tR tRt o ]P
                  ! . R	O]P                  R7      tR tR t	R t
R tRtV tR# )
TestRandomDirichleti  r   c                   V P                  V\        P                  4       V P                  VP                  \        P
                  4       Vf'   V P                  VP                  \        V4      4       Mh\        V4      \        J d)   V P                  VP                  V\        V4      34       M-V P                  VP                  V\        V4      3,           4        \        P                  ! V4       F'  pV P                  V^ 4       V P                  V^4       K)  	  Vf%   V P                  VP                  4       ^^R7       R# \        P                  ! VP                  RR7      4       F  pV P                  V^^R7       K  	  R# )zCheck output structureN)places)axisr   )r   r   r'  r   r   r,  r6   r   typer   r  nditerr$  r%  assertAlmostEqualr  )r   rF   r6   r  r  totalss   &&&&  r   r  !TestRandomDirichlet._check_sample  s     	fbjj1rzz2<V[[#e*5$Z3V\\D#e*+=>V\\43u:-+?@*99V$C##C+  a( % <""6::<1"=))FJJBJ$78&&vq&; 9r   c                X   \        RR7      ! \        4      pV P                  \        V P                  4      \        P
                  ! . RO\        P                  R7      \        P
                  ! . RO\        P                  R7      3pV F  pV! V4      pV P                  VRV4       K   	  R# )"
Test dirichlet(alpha, size=None)
Tr_   r   Nr   r   r  r   r   r   r  r   )r   rI   rF   r   r   r   r,  r  )r   r  alphasrF   r)  s   &    r   test_dirichlet_default*TestRandomDirichlet.test_dirichlet_default  sz     T"#:;JJ$**HH%RZZ8HH^2::6	
 E,CudC0 r   c                   \        RR7      ! \        4      pRpV P                  \        V P                  4      \        P
                  ! . RO\        P                  R7      \        P
                  ! . RO\        P                  R7      3p\        P                  ! W24       F  w  rEV! WE4      pV P                  WEV4       K!  	  R# )r  Tr_   Nr   )Nr   r   r   r  r  )
r   rG   rF   r   r   r   r,  	itertoolsproductr  )r   r  r  r  rF   r6   r)  s   &      r   test_dirichlet"TestRandomDirichlet.test_dirichlet  s     T"?3'JJ$**HH%RZZ8HH^2::6	
 %,,V;KE$CuC0 <r   c           
     r   \        R R7      ! \        4      p\        R4      pV P                  \        4      ;_uu_ 4       pV! V^4       RRR4       V P                  R\        XP                  4      4       V P                  pR RRRR	R
\        P                  ! ^4      \        P                  ! ^4      33pV FV  pV P                  \        4      ;_uu_ 4       pV! W%4       RRR4       V P                  R\        VP                  4      4       KX  	  R#   + '       g   i     L; i  + '       g   i     LN; i)Tr_   Nzdirichlet: alpha must be > 0.0              @r  zGnp.random.dirichlet(): size should be int or tuple of ints or None, got)r   r   r   r  r   r  r   r  r  )r   rG   r   r  rk  r(  str	exceptionrF   r   int8ry  r   )r   r  rF   raisesr  r6   s   &     r   test_dirichlet_exceptions-TestRandomDirichlet.test_dirichlet_exceptions  s    T"?3i z**f%O +6F<L<L8MN

r3'8bggaj"((ST+=VWD"";//6e" 0MM-F$$%  +* 0/s   
D	D&D#	&D6r   N)r   r   r   r   )r   r   r   r   r   r   r,  rF   r  r  r  r  r   r   r   s   @r   r  r    s2     HH\4E<,11" r   r  c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )TestRandomNoncentralChiSquarei  c                   Ve   V P                  V\        P                  4       V P                  VP                  \        P
                  4       \        V\        4      '       d   V P                  VP                  V34       M3V P                  VP                  V4       MV P                  V\        4       \        P                  ! V4       F  pV P                  V^ 4       K  	  R # r   )r   r   r'  r   r   r,  r  r   r  r  r  r$  )r   r6   r  r  s   &&& r   r  +TestRandomNoncentralChiSquare._check_sample  s     !!&"**5V\\2::6$$$  w7  t4""651 99V$C##C+ %r   c                    \        RR7      ! \        4      pRpV F[  w  r4V! W44      pV P                  RV4       V! V\        P                  4      pV P                  \        P                  ! V4      4       K]  	  R# )z0
Test noncentral_chisquare(df, nonc, size=None)
Tr_   N)r<  r   r  )rd  r   )r[  r   )r   r  )r   rQ   r  r   nanr?  isnan)r   r  inputsrM   rN   r)  s   &     r   !test_noncentral_chisquare_default?TestRandomNoncentralChiSquare.test_noncentral_chisquare_default)  sf     T"#EF
 HB/CtS)BFF#COOBHHSM*	 r   c                H   \        RR7      ! \        4      pRpRp\        P                  ! W24       Fm  w  w  rEpV! WEV4      pV P	                  Wg4       V! V\
        P                  V4      pV P                  \
        P                  ! V4      P                  4       4       Ko  	  R# )z+
Test noncentral_chisquare(df, nonc, size)
Tr_   N)Nr   r  r  r  )
r   rO   r  r  r  r   r  r?  r  ra  )r   r  r  r  rM   rN   r6   r)  s   &       r   test_noncentral_chisquare7TestRandomNoncentralChiSquare.test_noncentral_chisquare<  s     T"#=>+
 !* 1 1& @JR$'Ct)BFFD)COOBHHSM--/0	 !Ar   c           
     (   \        R R7      ! \        4      p^ ^r2V P                  \        4      ;_uu_ 4       pV! W#^4       RRR4       V P	                  R\        XP                  4      4       ^Rr2V P                  \        4      ;_uu_ 4       pV! W#^4       RRR4       V P	                  R\        VP                  4      4       ^^r2R RRR	R
R\        P                  ! ^4      \        P                  ! ^4      33pV FW  pV P                  \        4      ;_uu_ 4       pV! W#V4       RRR4       V P	                  R\        VP                  4      4       KY  	  R#   + '       g   i     EL"; i  + '       g   i     L; i  + '       g   i     Lb; i)Tr_   Nzdf <= 0znonc < 0r  r  zRnp.random.noncentral_chisquare(): size should be int or tuple of ints or None, gotr   r  r  r  )r   rO   r  rk  r(  r   r  r   r  ry  r   )r   r  rM   rN   r  r  r6   s   &      r   $test_noncentral_chisquare_exceptionsBTestRandomNoncentralChiSquare.test_noncentral_chisquare_exceptionsP  s0   T"#=>aDz**f"A +iV%5%5!67bDz**f"A +j#f&6&6"78aDr3'8bggaj"((ST+=VWD"";//6b% 0MM-F$$%  +**
 +* 0/s#   
E
E.
FE+	.E>	Fr   N)
r   r   r   r   r  r  r  r  r   r   r   s   @r   r  r    s     ,$+&1( r   r  T)r`   nogilc                     V ^ 8w  d   \         P                  ! V 4       \        VP                  4       F  p\         P                  ! ^ 4      W&   K  	  R# rT  )r   rS   r   r6   r  )rS   r  r   s   && r   py_extract_randomnessr  g  s9    qyD388_##B' r   c                     V ^ 8w  d    \         P                  P                  V 4       ^ p\        VP                  4       F(  p\         P                  P                  \        4      W&   K*  	  R# rT  )r   r   rS   r   r6   r   _randint_limit)rS   r  r  r   s   &&  r   np_extract_randomnessr  p  sF    qy
		t	A388_"">2 r   c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	ConcurrencyBaseTestiz  r[  c                P    ^*V P                  ^4      3p\        V!   \        V!   R# )*   N)_get_outputr  r  )r   r.  s   & r   setUpConcurrencyBaseTest.setUp  s'    D$$Q'(t$t$r   c                N    \         P                  ! V\         P                  R 7      # )r   )r   zerosr   )r   r6   s   &&r   r!  ConcurrencyBaseTest._get_output  s    xxBII..r   c                   RpR\         P                  ! ^4      ,          pRp\         P                  P                  VP	                  4       W$R7       \         P                  P                  VP                  4       W4R7       R# )z)
Check statistical properties of output.
g?)rtolNrx  r;  )r   r'  r  r  rb  std)r   r  expected_avgexpected_stdr(  s   &&   r   check_output ConcurrencyBaseTest.check_output  sZ    
 2772;.


""388:|"G


""3779l"Fr   c                   V F  pV P                  V4       K  	  V'       d   ^pM\        V4      pV Uu0 uF  p\        VR,          4      kK  	  ppV Uu0 uF  p\        VRR 4      kK  	  ppV Uu0 uF  q3P                  4       kK  	  ppV P	                  \        V4      WE4       V P	                  \        V4      WF4       V P	                  \        V4      WG4       R# u upi u upi u upi )r   :Nrd  NNrj  )r,  r   r   r  r   )r   r/  same_expectedr  expected_distinctheadstailssumss   &&&     r   check_several_outputs)ConcurrencyBaseTest.check_several_outputs  s     Cc" 
  ! #G+237Cs2w73,34GSs23xG4%,-Wc	W-U%6>U%6>T$5< 44-s   C C%3C*r   N)r   r   r   r   _extract_iterationsr"  r!  r,  r4  r   r   r   s   @r   r  r  z  s'      !%/	G= =r   r  c                   N   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
tV tR# )TestThreadsi  z+
Check the PRNG behaves well with threads.
c                z  aaa \        V^,           4       Uu. uF  pV P                  V P                  4      NK   	  upoVVV3R lp\        V4       Uu. uF  p\        P                  ! WT3R7      NK  	  ppV F  pVP                  4        K  	  V! V4       V F  pVP                  4        K  	  S# u upi u upi )zW
Run *nthreads* threads extracting randomness with the given *seed*
(no seeding if 0).
c                 *   < S! SSV ,          R 7       R# )rS   r  Nr   )r   extract_randomnessr/  rS   s   &r   target.TestThreads.extract_in_threads.<locals>.target  s    Dgaj9r   )r=  r.  )r   r!  r6  	threadingThreadstartrl   )	r   nthreadsr<  rS   r   r=  threadsthr/  s	   &&ff    @r   extract_in_threadsTestThreads.extract_in_threads  s     "(Q,/1/q ##D$<$<=/1	:
 "(O-+q ##6=+ 	 - BHHJ  	xBGGI  #1-s   $B3!B8c                T    V P                  ^V^*R7      pV P                  VRR7       R# )z
When initializing the PRNG the same way, each thread
should produce the same sequence of random numbers,
using independent states, regardless of parallel
execution.
ru  Tr/  NrE  r4  r   r<  r/  s   && r   check_thread_safetyTestThreads.check_thread_safety  s1     ))".@r)J 	""7$"?r   c                T    V P                  ^V^ R7      pV P                  VRR7       R# )zh
The PRNG in new threads should be implicitly initialized with
system entropy, if seed() wasn't called.
ru  FrH  NrI  rJ  s   && r   check_implicit_initialization)TestThreads.check_implicit_initialization  s1    
 ))!-?a)H 	""7%"@r   c                0    V P                  \        4       R # r   )rK  r  r   s   &r   test_py_thread_safety!TestThreads.test_py_thread_safety        !67r   c                0    V P                  \        4       R # r   )rK  r  r   s   &r   test_np_thread_safety!TestThreads.test_np_thread_safety  rS  r   c                0    V P                  \        4       R # r   rN  r  r   s   &r   test_py_implicit_initialization+TestThreads.test_py_implicit_initialization      **+@Ar   c                0    V P                  \        4       R # r   rN  r  r   s   &r   test_np_implicit_initialization+TestThreads.test_np_implicit_initialization  r[  r   r   N)r   r   r   r   r   rE  rK  rN  rQ  rU  rY  r^  r   r   r   s   @r   r8  r8    s7     0@A88BB Br   r8  ntz(Windows is not affected by fork() issuesc                   @   a  ] tR tRt o RtRtR tR tR tR t	Rt
V tR	# )
TestProcessesi  z1
Check the PRNG behaves well in child processes.
Fc                ~  a aa
a \         P                  ! 4       o
. pVV 3R loV
V3R lp\        \         R4      '       d   \         P                  ! R4      pM\         p\	        V4       Uu. uF  pVP                  VR7      NK  	  ppV F  pVP                  4        K  	  \	        V4       F$  pVP                  S
P                  ^R7      4       K&  	  V F  pVP                  4        K  	  VP                  S! 4       4       V F0  p	\        V	\        4      '       g   K  S P                  RV	: 24       K2  	  V# u upi )zH
Run *nprocs* processes extracting randomness
without explicit seeding.
c                  R   < SP                  SP                  4      p S! ^ V R7       V # )r   r;  )r!  r6  )r  r<  r   s    r   target_inner8TestProcesses.extract_in_processes.<locals>.target_inner  s(    ""4#;#;<CA3/Jr   c                     <  S! 4       p SP                  V 4       R #   \         d   pSP                  T4       h R p?ii ; ir   )put	Exception)r  eqre  s     r   r=  2TestProcesses.extract_in_processes.<locals>.target  s:    "nc
  a	s    ?:?get_contextfork)r=  )timeoutzException in child: )multiprocessingQueuehasattrrm  r   ProcessrA  r   getrl   r  ri  fail)r   nprocsr<  r/  r=  mpcr   procsr  r)  rk  re  s   f&f       @@r   extract_in_processes"TestProcesses.extract_in_processes  s   
 !!#	
	 ?M22!--f5C!C-)'Q F+' 	 )AGGI  vANN1555+, AFFH 
 	|~&C#y))		c;<  %)s   *D:c                P    V P                  ^V4      pV P                  VRR7       R# )zz
The PRNG in new processes should be implicitly initialized
with system entropy, to avoid reproducing the same sequences.
FrH  N)ry  r4  rJ  s   && r   rN  +TestProcesses.check_implicit_initialization)  s,    
 ++A/AB 	""7%"@r   c                0    V P                  \        4       R # r   rX  r   s   &r   rY  -TestProcesses.test_py_implicit_initialization3  r[  r   c                0    V P                  \        4       R # r   r]  r   s   &r   r^  -TestProcesses.test_np_implicit_initialization6  r[  r   r   N)r   r   r   r   r   _numba_parallel_test_ry  rN  rY  r^  r   r   r   s   @r   rb  rb    s0      ".`ABB Br   rb  c                     a  ] tR tRt o / RRRRRR^/bRR	^R
RR^/bRRRR^/bRR^R^/bRRRPR^/bRRRR^/bRRRRRR^/bRR^RRR^/bRR
RR^/bRRRRRR^/bRR^R^R^R^/bR RRRRR^/bR!RRRRR^/bR"R#RR$RR^/bR%R
R&R^/bR'R	^R(RQR^/bR)R	^R
R&/b/ R*RRR+RR^/bR,RRRRR^/bR-RRR^/bR.R/RR^/bR0RRR^/bR1R2^R3^R^/bR4R^/bR5R^/bR6R^/bR7RRR^/bR8R^/bR9R:^/bR;R^/bR<R^/bR=RRR^/bR>R^/bR?RRR^/bCR@RARRBRRCRDR^/RER2RR3RR^/RFRGRRHRR^/RIR#RRRR^/RJRRR^/RKRRR^//CtRL tRM tRNtV tRO# )RTestNumPyRandomAPIi:  r  r   r   r"   r   r6   r  r>   r  r  r,  rM   znp.random.choiceznp.random.dirichletrF   r  rM  r4  dfnumdfdenr  r  r:  rD  rL  r   rR  ngoodnbadnsamplerg  ro  r_  rb  sigmart  r<  znp.random.multinomialr?   r  znp.random.noncentral_chisquarerN   r~   r  r|  lamr  znp.random.randintr  r  r   r  r  r  r  r   rS   r  r  r  rP  r  r  leftmoderightg      @r  r  mukappar  r  r  c           
     j   V P                   P                  4        F  w  rR P                  VP                  4        UUu. uF  w  r4V RV 2NK  	  upp4      p\        RV RV R24      p/ p\	        VR\
        /V4       VR,          pV! 4        \        V4      P                  R4       K  	  R# u uppi )	r  rj   7
                def foo():
                    return rk   )
                r   fooNr   )API_CALL_TESTSitemsrl   r   execr   r   compile)	r   fnr.  r  vargstrtemplater  r^   s	   &        r   test_call_by_name$TestNumPyRandomAPI.test_call_by_namer  s     ++113HBYYtzz|D|tq1#Qqc
|DEF #4q ) H AD":q)
 U8DFJr" 4Ds   B/c           
     ^   V P                   P                  4        EF  w  rR V9  d   K  R	VR &   RP                  VP                  4        UUu. uF  w  r4V RV 2NK  	  upp4      p\        RV RV R24      p/ p\	        VR\
        /V4       VR,          pV! 4       p	\        V4      P                  R	4      p
V
! 4       p\        V\
        P                  4      '       d)   V P                  VP                  V	P                  4       K  V P                  WP                  4       EK
  	  R# u uppi )
r6   r  rj   r  rk   r  r   r  Nr   )r  r  rl   r   r  r   r   r  r  r'  r   r  r   	__class__)r   r  r.  r  r  r  r  r  r^   np_valnb_funcnb_vals   &           r   'test_call_distributions_with_empty_size:TestNumPyRandomAPI.test_call_distributions_with_empty_size  s    ++113HBT!DLYYtzz|D|tq1#Qqc
|DEF #4q ) H AD":q) U8DVF4j((,GYF&"**--  v||<%%f.>.>?5 4
  Es   D)r   Nr   )r   )	r   r   r   r   r  r  r  r   r   r   s   @r   r  r  :  s    5?&b#r61(E 5?*S!S#vq,I5?+dB-B5? )361*=5? ,gtVQ-G	5?
 .VQ/G5? $gr7B%J5? ('1gsFA)N5? ,c2vq-A5? )5"gr61*M5? 17Avq3<a3L5? *E2wFA+N5? +UBVQ,O5? ,fb'2vq-Q5? ,c3-B5?  .Qvq/Q!5?" 4c1c35G#5?$ 7r629?9D%5?( )5"gr61*M)5?* )3FA*>+5?2 *E2vq+A35?4 (#r61)=55?< *E1fa+K=5?D )61+E5?F 0&!G5?H 'I5?J +Wb&!,DK5?L )61+M5?N 'O5?T 2FA;U5?V 7W5?X 17B2JY5?Z 2FA;[5?\ -tR.C]5?^ -vr62wPR/5q/:)E2vr61+M*T2wFA,N&Wb&!(L)CVQ+?&b&!(<k5?Nn#4@ @r   r  __main__r;  )Sr  r.  r&  rp  r   r   r  r  r?  r  textwrapr   numpyr   unittestr   r   r   r   
numba.corer   numba.tests.supportr   r	   r
   numba.core.errorsr   r   r   r   r   r#   r%   r)   r+   r.   r2   r7   r:   r@   rB   rG   rI   rO   rQ   rX   r\   rg   rq   rv   rx   rz   r|   r  r   r   r  r	  r  r   r   r   r   r   r   r   r   r  r~  r  r  r  r  r  r  r  r8  skipIfrc   rb  r  r   mainr   r   r   <module>r     sM       	   
       ' '  ? ? ) -- # "%*;+<1&?4&&#$'* .)O,&,--.'(
"/,

x 
A0H A0Hm* m*`]/x ]/@s9x s9lA1H A1HI( IVPH Pd d$(  ( d$3  3/=( /=d?B% ?BD 
D"LMHB' HB NHBVo@ o@h zMMO r   