62
62
63
63
64
64
def test_mixture_basics ():
65
- srng = pt .random .RandomStream (29833 )
66
-
67
65
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" )
70
68
71
69
p_at = pt .scalar ("p" )
72
70
p_at .tag .test_value = 0.5
73
71
74
- I_rv = srng .bernoulli (p_at , size = size , name = "I" )
72
+ I_rv = pt . random .bernoulli (p_at , size = size , name = "I" )
75
73
i_vv = I_rv .clone ()
76
74
i_vv .name = "i"
77
75
@@ -119,15 +117,13 @@ def create_mix_model(size, axis):
119
117
],
120
118
)
121
119
def 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" )
126
122
127
123
p_at = pt .scalar ("p" )
128
124
p_at .tag .test_value = 0.3
129
125
130
- I_rv = srng .bernoulli (p_at , name = "I" )
126
+ I_rv = pt . random .bernoulli (p_at , name = "I" )
131
127
132
128
i_vv = I_rv .clone ()
133
129
i_vv .name = "i"
@@ -160,20 +156,18 @@ def test_compute_test_value(op_constructor):
160
156
],
161
157
)
162
158
def 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" )
167
161
168
162
if np .ndim (p_val ) == 0 :
169
163
p_at = pt .scalar ("p" )
170
164
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" )
172
166
p_val_1 = p_val
173
167
else :
174
168
p_at = pt .vector ("p" )
175
169
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" )
177
171
p_val_1 = p_val [1 ]
178
172
179
173
i_vv = I_rv .clone ()
@@ -203,7 +197,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
203
197
204
198
bern_sp = sp .bernoulli (p_val_1 )
205
199
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 )
207
201
208
202
for i in range (10 ):
209
203
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):
230
224
),
231
225
(
232
226
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 ),
234
228
),
235
229
(
236
230
np .array (100 , dtype = pytensor .config .floatX ),
@@ -251,7 +245,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
251
245
),
252
246
(
253
247
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 ),
255
249
),
256
250
(
257
251
np .array ([100 ], dtype = pytensor .config .floatX ),
@@ -272,7 +266,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
272
266
),
273
267
(
274
268
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 ),
276
270
),
277
271
(
278
272
np .array ([100 ], dtype = pytensor .config .floatX ),
@@ -293,7 +287,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
293
287
),
294
288
(
295
289
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 ),
297
291
),
298
292
(
299
293
np .array (100 , dtype = pytensor .config .floatX ),
@@ -314,7 +308,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
314
308
),
315
309
(
316
310
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 ),
318
312
),
319
313
(
320
314
np .array (100 , dtype = pytensor .config .floatX ),
@@ -335,7 +329,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
335
329
),
336
330
(
337
331
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 ),
339
333
),
340
334
(
341
335
np .array (100 , dtype = pytensor .config .floatX ),
@@ -361,7 +355,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
361
355
),
362
356
(
363
357
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 ),
365
359
),
366
360
(
367
361
np .array (100 , dtype = pytensor .config .floatX ),
@@ -384,7 +378,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
384
378
),
385
379
(
386
380
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 ),
388
382
),
389
383
(
390
384
np .array (100 , dtype = pytensor .config .floatX ),
@@ -405,7 +399,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
405
399
),
406
400
(
407
401
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 ),
409
403
),
410
404
(
411
405
np .array (100 , dtype = pytensor .config .floatX ),
@@ -426,7 +420,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
426
420
),
427
421
(
428
422
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 ),
430
424
),
431
425
(
432
426
np .array (100 , dtype = pytensor .config .floatX ),
@@ -447,7 +441,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
447
441
),
448
442
(
449
443
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 ),
451
445
),
452
446
(
453
447
np .array ([100 ], dtype = pytensor .config .floatX ),
@@ -468,7 +462,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
468
462
),
469
463
(
470
464
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 ),
472
466
),
473
467
(
474
468
np .array ([100 , 1000 ], dtype = pytensor .config .floatX ),
@@ -489,7 +483,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
489
483
),
490
484
(
491
485
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 ),
493
487
),
494
488
(
495
489
np .array ([100 , 1000 ], dtype = pytensor .config .floatX ),
@@ -510,7 +504,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
510
504
),
511
505
(
512
506
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 ),
514
508
),
515
509
(
516
510
np .array (100 , dtype = pytensor .config .floatX ),
@@ -531,7 +525,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
531
525
),
532
526
(
533
527
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 ),
535
529
),
536
530
(
537
531
np .array (100 , dtype = pytensor .config .floatX ),
@@ -552,7 +546,7 @@ def test_hetero_mixture_binomial(p_val, size, supported):
552
546
),
553
547
(
554
548
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 ),
556
550
),
557
551
(
558
552
np .array (100 , dtype = pytensor .config .floatX ),
@@ -570,16 +564,14 @@ def test_hetero_mixture_binomial(p_val, size, supported):
570
564
def test_hetero_mixture_categorical (
571
565
X_args , Y_args , Z_args , p_val , comp_size , idx_size , extra_indices , join_axis , supported
572
566
):
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" )
578
570
579
571
p_at = pt .as_tensor (p_val ).type ()
580
572
p_at .name = "p"
581
573
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" )
583
575
584
576
i_vv = I_rv .clone ()
585
577
i_vv .name = "i"
@@ -612,7 +604,7 @@ def test_hetero_mixture_categorical(
612
604
test_val_rng = np .random .RandomState (3238 )
613
605
614
606
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 ])
616
608
norm_2_sp = sp .norm (loc = Z_args [0 ], scale = Z_args [1 ])
617
609
618
610
# Handle scipy annoying squeeze of random draws
0 commit comments