6262
6363
6464def test_mixture_basics ():
65- srng = pt .random .RandomStream (29833 )
66-
6765 def create_mix_model (size , axis ):
68- X_rv = srng .normal (0 , 1 , size = size , name = "X" )
69- Y_rv = srng . gamma (0.5 , 0.5 , size = size , name = "Y" )
66+ X_rv = pt . random .normal (0 , 1 , size = size , name = "X" )
67+ Y_rv = pt . random . gamma (0.5 , scale = 2.0 , size = size , name = "Y" )
7068
7169 p_at = pt .scalar ("p" )
7270 p_at .tag .test_value = 0.5
7371
74- I_rv = srng .bernoulli (p_at , size = size , name = "I" )
72+ I_rv = pt . random .bernoulli (p_at , size = size , name = "I" )
7573 i_vv = I_rv .clone ()
7674 i_vv .name = "i"
7775
@@ -119,15 +117,13 @@ def create_mix_model(size, axis):
119117 ],
120118)
121119def test_compute_test_value (op_constructor ):
122- srng = pt .random .RandomStream (29833 )
123-
124- X_rv = srng .normal (0 , 1 , name = "X" )
125- Y_rv = srng .gamma (0.5 , 0.5 , name = "Y" )
120+ X_rv = pt .random .normal (0 , 1 , name = "X" )
121+ Y_rv = pt .random .gamma (0.5 , scale = 2.0 , name = "Y" )
126122
127123 p_at = pt .scalar ("p" )
128124 p_at .tag .test_value = 0.3
129125
130- I_rv = srng .bernoulli (p_at , name = "I" )
126+ I_rv = pt . random .bernoulli (p_at , name = "I" )
131127
132128 i_vv = I_rv .clone ()
133129 i_vv .name = "i"
@@ -160,20 +156,18 @@ def test_compute_test_value(op_constructor):
160156 ],
161157)
162158def test_hetero_mixture_binomial (p_val , size , supported ):
163- srng = pt .random .RandomStream (29833 )
164-
165- X_rv = srng .normal (0 , 1 , size = size , name = "X" )
166- Y_rv = srng .gamma (0.5 , 0.5 , size = size , name = "Y" )
159+ X_rv = pt .random .normal (0 , 1 , size = size , name = "X" )
160+ Y_rv = pt .random .gamma (0.5 , scale = 2.0 , size = size , name = "Y" )
167161
168162 if np .ndim (p_val ) == 0 :
169163 p_at = pt .scalar ("p" )
170164 p_at .tag .test_value = p_val
171- I_rv = srng .bernoulli (p_at , size = size , name = "I" )
165+ I_rv = pt . random .bernoulli (p_at , size = size , name = "I" )
172166 p_val_1 = p_val
173167 else :
174168 p_at = pt .vector ("p" )
175169 p_at .tag .test_value = np .array (p_val , dtype = pytensor .config .floatX )
176- I_rv = srng .categorical (p_at , size = size , name = "I" )
170+ I_rv = pt . random .categorical (p_at , size = size , name = "I" )
177171 p_val_1 = p_val [1 ]
178172
179173 i_vv = I_rv .clone ()
@@ -203,7 +197,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
203197
204198 bern_sp = sp .bernoulli (p_val_1 )
205199 norm_sp = sp .norm (loc = 0 , scale = 1 )
206- gamma_sp = sp .gamma (0.5 , scale = 1.0 / 0.5 )
200+ gamma_sp = sp .gamma (0.5 , scale = 2.0 )
207201
208202 for i in range (10 ):
209203 i_val = bern_sp .rvs (size = size , random_state = test_val_rng )
@@ -230,7 +224,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
230224 ),
231225 (
232226 np .array (0.5 , dtype = pytensor .config .floatX ),
233- np .array (0.5 , dtype = pytensor .config .floatX ),
227+ np .array (2.0 , dtype = pytensor .config .floatX ),
234228 ),
235229 (
236230 np .array (100 , dtype = pytensor .config .floatX ),
@@ -251,7 +245,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
251245 ),
252246 (
253247 np .array ([0.5 ], dtype = pytensor .config .floatX ),
254- np .array (0.5 , dtype = pytensor .config .floatX ),
248+ np .array (2.0 , dtype = pytensor .config .floatX ),
255249 ),
256250 (
257251 np .array ([100 ], dtype = pytensor .config .floatX ),
@@ -272,7 +266,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
272266 ),
273267 (
274268 np .array ([0.5 ], dtype = pytensor .config .floatX ),
275- np .array (0.5 , dtype = pytensor .config .floatX ),
269+ np .array (2.0 , dtype = pytensor .config .floatX ),
276270 ),
277271 (
278272 np .array ([100 ], dtype = pytensor .config .floatX ),
@@ -293,7 +287,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
293287 ),
294288 (
295289 np .array (0.5 , dtype = pytensor .config .floatX ),
296- np .array (0.5 , dtype = pytensor .config .floatX ),
290+ np .array (2.0 , dtype = pytensor .config .floatX ),
297291 ),
298292 (
299293 np .array (100 , dtype = pytensor .config .floatX ),
@@ -314,7 +308,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
314308 ),
315309 (
316310 np .array (0.5 , dtype = pytensor .config .floatX ),
317- np .array (0.5 , dtype = pytensor .config .floatX ),
311+ np .array (2.0 , dtype = pytensor .config .floatX ),
318312 ),
319313 (
320314 np .array (100 , dtype = pytensor .config .floatX ),
@@ -335,7 +329,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
335329 ),
336330 (
337331 np .array (0.5 , dtype = pytensor .config .floatX ),
338- np .array (0.5 , dtype = pytensor .config .floatX ),
332+ np .array (2.0 , dtype = pytensor .config .floatX ),
339333 ),
340334 (
341335 np .array (100 , dtype = pytensor .config .floatX ),
@@ -361,7 +355,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
361355 ),
362356 (
363357 np .array (0.5 , dtype = pytensor .config .floatX ),
364- np .array (0.5 , dtype = pytensor .config .floatX ),
358+ np .array (2.0 , dtype = pytensor .config .floatX ),
365359 ),
366360 (
367361 np .array (100 , dtype = pytensor .config .floatX ),
@@ -384,7 +378,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
384378 ),
385379 (
386380 np .array (0.5 , dtype = pytensor .config .floatX ),
387- np .array (0.5 , dtype = pytensor .config .floatX ),
381+ np .array (2.0 , dtype = pytensor .config .floatX ),
388382 ),
389383 (
390384 np .array (100 , dtype = pytensor .config .floatX ),
@@ -405,7 +399,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
405399 ),
406400 (
407401 np .array (0.5 , dtype = pytensor .config .floatX ),
408- np .array (0.5 , dtype = pytensor .config .floatX ),
402+ np .array (2.0 , dtype = pytensor .config .floatX ),
409403 ),
410404 (
411405 np .array (100 , dtype = pytensor .config .floatX ),
@@ -426,7 +420,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
426420 ),
427421 (
428422 np .array (0.5 , dtype = pytensor .config .floatX ),
429- np .array (0.5 , dtype = pytensor .config .floatX ),
423+ np .array (2.0 , dtype = pytensor .config .floatX ),
430424 ),
431425 (
432426 np .array (100 , dtype = pytensor .config .floatX ),
@@ -447,7 +441,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
447441 ),
448442 (
449443 np .array ([0.5 ], dtype = pytensor .config .floatX ),
450- np .array (0.5 , dtype = pytensor .config .floatX ),
444+ np .array (2.0 , dtype = pytensor .config .floatX ),
451445 ),
452446 (
453447 np .array ([100 ], dtype = pytensor .config .floatX ),
@@ -468,7 +462,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
468462 ),
469463 (
470464 np .array ([0.5 , 1 ], dtype = pytensor .config .floatX ),
471- np .array ([0.5 , 1 ], dtype = pytensor .config .floatX ),
465+ np .array ([2.0 , 1 ], dtype = pytensor .config .floatX ),
472466 ),
473467 (
474468 np .array ([100 , 1000 ], dtype = pytensor .config .floatX ),
@@ -489,7 +483,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
489483 ),
490484 (
491485 np .array ([0.5 , 1 ], dtype = pytensor .config .floatX ),
492- np .array ([0.5 , 1 ], dtype = pytensor .config .floatX ),
486+ np .array ([2.0 , 1 ], dtype = pytensor .config .floatX ),
493487 ),
494488 (
495489 np .array ([100 , 1000 ], dtype = pytensor .config .floatX ),
@@ -510,7 +504,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
510504 ),
511505 (
512506 np .array (0.5 , dtype = pytensor .config .floatX ),
513- np .array (0.5 , dtype = pytensor .config .floatX ),
507+ np .array (2.0 , dtype = pytensor .config .floatX ),
514508 ),
515509 (
516510 np .array (100 , dtype = pytensor .config .floatX ),
@@ -531,7 +525,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
531525 ),
532526 (
533527 np .array (0.5 , dtype = pytensor .config .floatX ),
534- np .array (0.5 , dtype = pytensor .config .floatX ),
528+ np .array (2.0 , dtype = pytensor .config .floatX ),
535529 ),
536530 (
537531 np .array (100 , dtype = pytensor .config .floatX ),
@@ -552,7 +546,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
552546 ),
553547 (
554548 np .array (0.5 , dtype = pytensor .config .floatX ),
555- np .array (0.5 , dtype = pytensor .config .floatX ),
549+ np .array (2.0 , dtype = pytensor .config .floatX ),
556550 ),
557551 (
558552 np .array (100 , dtype = pytensor .config .floatX ),
@@ -570,16 +564,14 @@ def test_hetero_mixture_binomial(p_val, size, supported):
570564def test_hetero_mixture_categorical (
571565 X_args , Y_args , Z_args , p_val , comp_size , idx_size , extra_indices , join_axis , supported
572566):
573- srng = pt .random .RandomStream (29833 )
574-
575- X_rv = srng .normal (* X_args , size = comp_size , name = "X" )
576- Y_rv = srng .gamma (* Y_args , size = comp_size , name = "Y" )
577- Z_rv = srng .normal (* Z_args , size = comp_size , name = "Z" )
567+ X_rv = pt .random .normal (* X_args , size = comp_size , name = "X" )
568+ Y_rv = pt .random .gamma (Y_args [0 ], scale = Y_args [1 ], size = comp_size , name = "Y" )
569+ Z_rv = pt .random .normal (* Z_args , size = comp_size , name = "Z" )
578570
579571 p_at = pt .as_tensor (p_val ).type ()
580572 p_at .name = "p"
581573 p_at .tag .test_value = np .array (p_val , dtype = pytensor .config .floatX )
582- I_rv = srng .categorical (p_at , size = idx_size , name = "I" )
574+ I_rv = pt . random .categorical (p_at , size = idx_size , name = "I" )
583575
584576 i_vv = I_rv .clone ()
585577 i_vv .name = "i"
@@ -612,7 +604,7 @@ def test_hetero_mixture_categorical(
612604 test_val_rng = np .random .RandomState (3238 )
613605
614606 norm_1_sp = sp .norm (loc = X_args [0 ], scale = X_args [1 ])
615- gamma_sp = sp .gamma (Y_args [0 ], scale = 1 / Y_args [1 ])
607+ gamma_sp = sp .gamma (Y_args [0 ], scale = Y_args [1 ])
616608 norm_2_sp = sp .norm (loc = Z_args [0 ], scale = Z_args [1 ])
617609
618610 # Handle scipy annoying squeeze of random draws
0 commit comments