Skip to content

as_tensor_variable(range(n)) should work #2127

@williambdean

Description

@williambdean

as_tensor_variable(range(n)) currently raises NotImplementedError because there is no singledispatch handler for range objects.

Workaround: as_tensor_variable(list(range(n))).

Proposed fix: add a range handler in pytensor/tensor/basic.py that converts to a list and delegates to the existing sequence handler (same behavior as list/tuple). Empty ranges are already covered via the empty-sequence path.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions