-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Milestone
Description
Discussed in #6065
Originally posted by ricardoV94 August 25, 2022
Right now we can specify dims on the fly, which are taken from the shape of a variable:
import pymc as pm
with pm.Model() as m:
x = pm.Normal("x", shape=(3,), dims=("trial",))
print(m.dim_lengths["trial"].eval()) # 3
This is neat, but causes some code complexity, because we also allow dims to inform the shape of a variable.
with pm.Model(coords={"trial": range(3)}) as m:
x = pm.Normal("x", dims=("trial",))
print(x.eval().shape) # (3,)
Which forces us to create new variables in a two-step process, first without dim information and then with it (via resizing). Code could be simplified if we don't have to worry about dims being specified on the fly.
These two behaviors of dims are also potentially confusing when mixed together:
with pm.Model() as m:
x = pm.Normal("x", shape=5, dims=("trial",))
y = pm.Normal("y", dims=("trial",))
print(y.eval().shape) # (5,)
Metadata
Metadata
Assignees
Labels
No labels