Skip to content

point to location of as_xtensor #8009

@williambdean

Description

@williambdean

Not entirely obvious where this function lives.

import pymc as pm
import pymc.dims as pmd
from pytensor.xtensor import as_xtensor


coords = {"repo": ["pymc", "pymc-marketing"]}
with pm.Model(coords=coords) as model:
    lam = pmd.HalfNormal("lam", dims="repo")
    pmd.Exponential(
        "obs",
        lam=lam,
        observed=[5, 7],
        dims="repo",
    )
ValueError: Variable [5, 7] must have dims associated with it.
To avoid subtle bugs, PyMC does not make any assumptions about the dims of parameters.
Use `as_xtensor` with the `dims` keyword argument to specify the dims explicitly.

My suggestion would be to be more explicit here with pytensor.xtensor.as_xtensor:

raise ValueError(
f"Variable {x} must have dims associated with it.\n"
"To avoid subtle bugs, PyMC does not make any assumptions about the dims of parameters.\n"
"Use `as_xtensor` with the `dims` keyword argument to specify the dims explicitly."
)

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