Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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