google-deepmind / google-deepmind/chex

Improve assert_shape error message when Ellipsis is used as shape matcher

Open
#437 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
957
Forks
74
Avg merge
21h 10m
Merged PRs (30d)
1

Description

Using `chex.assert_shape(x, ...)` raises:

AssertionError: expected shapes should be a list or tuple of ints, got Ellipsis

However, Ellipsis works when wrapped in a tuple:

chex.assert_shape(x, (...,))

This makes it unclear whether `...` is unsupported or just incorrectly formatted.

Suggested improvement:
Clarify the error message to indicate a shape specification must be a sequence and suggest using `(...,)`.

Example improved message:
Expected a shape specification tuple, e.g. (...,) instead of bare Ellipsis (...)

Why this helps:
Users commonly interpret `...` as a valid wildcard shape and the current message implies a type mistake rather than guiding correct usage.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.