Skip to content

Name check on pt.tensor is too strict #1102

Open
@jessegrabowski

Description

@jessegrabowski

Description

a0 = pt.tensor(name="a0", dtype=floatX, shape=(m,))

Fails with the following error:

    a0 = pt.tensor(name="a0", dtype=floatX, shape=(m,))
/home/jesse/mambaforge/envs/pymc-statespace/lib/python3.11/site-packages/pytensor/tensor/type.py:791: in tensor
    raise ValueError(
E   ValueError: The first and only positional argument of tensor is now `name`. Got a0.
E   This name looks like a dtype, which you should pass as a keyword argument only.

There is a check here in pt.tensor that makes sure we're not passing a dtype as the only argument to pt.vector (for historical reasons I guess?). This is fine, but it shouldn't occur if the dtype is also specified. Fixing this would be as easy as changing the if condition to if name is not None and dtype is not None, since in that case I clearly did not want a0 interpreted as a dtype.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions