Skip to content

Improve assert_shape error message when Ellipsis is used as shape matcher #437

@OmAmbole009

Description

@OmAmbole009

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions