Skip to content

Consider having coords per variable #7852

Open
@ricardoV94

Description

@ricardoV94

Description

This is currently not possible to do correctly:

import pymc as pm

with pm.Model(coords={"time": range(4)}) as m:
  x = pm.Normal("x", dims=("time",))
  pm.Deterministic("x[1:]", x[1:], dims=("time",))
  idata = pm.sample()  # fails

Users have two options: Use a different dim with custom cords for x[1:] or don't specify dims for it, in which case it get's a different dim and default coords after sampling. Either way no option to retain the dim.

I suggest allowing coords to pm.Deterministic and keep track of coords per variable at the model level.

with pm.Model(coords={"time": range(4)}) as m:
  x = pm.Normal("x", dims=("time",))
  pm.Deterministic("x[1:]", x[1:], dims=("time",), coords={"time": range(1, 4)})
  idata = pm.sample()  # correct

With the awareness that coords don't do anything at the model level, only after exporting them

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