Skip to content

What makes TensorVariables iterable #141

Open
@michaelosthege

Description

@michaelosthege

Describe the issue:

These are as expected:

from collections,abc import Iterable
>>> isinstance(pt.constant([1,2,3]), Iterable)
True
>>> isinstance(pytensor.shared(np.array([1,2,3])), Iterable)
True

But a purely symbolic at.vector() that doesn't have a value yet raises and error when attempting to iterate it, because it has no length.

And even worse, a pt.scalar() should never be iterable to begin with.

Reproducable code example:

>>> isinstance(pt.vector(), Iterable)
True
>>> isinstance(pt.scalar(), Iterable)
True

Error message:

No response

PyTensor version information:

main

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions