Skip to content

Commit 042a1c5

Browse files
committed
Add rng update test for size from observed
1 parent 5392468 commit 042a1c5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pymc/tests/test_shape_handling.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,3 +485,18 @@ def test_size_from_dims_rng_update(self):
485485
# Confirm that the rng is properly offset, otherwise the second value of the first
486486
# draw, would match the first value of the second draw
487487
assert fn()[1] != fn()[0]
488+
489+
def test_size_from_observed_rng_update(self):
490+
"""Test that when setting size from observed we update the rng properly
491+
See https://github.com/pymc-devs/pymc/issues/5653
492+
"""
493+
with pm.Model():
494+
x = pm.Normal("x", observed=[0, 1])
495+
496+
fn = pm.aesaraf.compile_pymc([], x)
497+
# Check that both function outputs (rng and draws) come from the same Apply node
498+
assert fn.maker.fgraph.outputs[0].owner is fn.maker.fgraph.outputs[1].owner
499+
500+
# Confirm that the rng is properly offset, otherwise the second value of the first
501+
# draw, would match the first value of the second draw
502+
assert fn()[1] != fn()[0]

0 commit comments

Comments
 (0)