Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyro/poutine/subsample_messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def _subsample(
size = -1 # This is PyTorch convention for "arbitrary size"
subsample_size = -1
else:
if size < 0:
raise ValueError("size cannot be negative")
msg = Message(
type="sample",
name=name,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def test_deterministic_ok():
assert x.shape == ()


def test_plate_negative_size_error():
with pytest.raises(ValueError, match="size cannot be negative"):
pyro.plate("data", -1)


@pytest.mark.parametrize(
"mask",
[
Expand Down