File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -428,6 +428,36 @@ def test_mutable_coords_volatile(self):
428
428
"offsets" ,
429
429
}
430
430
431
+ def test_length_coords_volatile (self ):
432
+ with pm .Model () as model :
433
+ model .add_coord ("trial" , length = 3 )
434
+ x = pm .Normal ("x" , dims = "trial" )
435
+ y = pm .Deterministic ("y" , x .mean ())
436
+
437
+ # Same coord length -- `x` is not volatile
438
+ trace_same_len = az_from_dict (
439
+ posterior = {"x" : [[[np .pi ] * 3 ]]},
440
+ coords = {"trial" : range (3 )},
441
+ dims = {"x" : ["trial" ]},
442
+ )
443
+ with model :
444
+ pp_same_len = pm .sample_posterior_predictive (
445
+ trace_same_len , var_names = ["y" ]
446
+ ).posterior_predictive
447
+ assert pp_same_len ["y" ] == np .pi
448
+
449
+ # Coord length changed -- `x` is volatile
450
+ trace_diff_len = az_from_dict (
451
+ posterior = {"x" : [[[np .pi ] * 2 ]]},
452
+ coords = {"trial" : range (2 )},
453
+ dims = {"x" : ["trial" ]},
454
+ )
455
+ with model :
456
+ pp_diff_len = pm .sample_posterior_predictive (
457
+ trace_diff_len , var_names = ["y" ]
458
+ ).posterior_predictive
459
+ assert pp_diff_len ["y" ] != np .pi
460
+
431
461
432
462
class TestSamplePPC :
433
463
def test_normal_scalar (self ):
You can’t perform that action at this time.
0 commit comments