Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support of "dims on the fly" #6085

Closed
twiecki opened this issue Aug 31, 2022 Discussed in #6065 · 0 comments · Fixed by #6112
Closed

Remove support of "dims on the fly" #6085

twiecki opened this issue Aug 31, 2022 Discussed in #6065 · 0 comments · Fixed by #6112
Milestone

Comments

@twiecki
Copy link
Member

twiecki commented Aug 31, 2022

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,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants