Skip to content

Reasses dims without coords #7048

New issue

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

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

Already on GitHub? # to your account

Open
ricardoV94 opened this issue Dec 4, 2023 · 1 comment
Open

Reasses dims without coords #7048

ricardoV94 opened this issue Dec 4, 2023 · 1 comment

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Dec 4, 2023

Description

It is currently possible to create dims without coords via pm.Data:

import pymc as pm

with pm.Model() as m:
  x = pm.MutableData("x", [0, 1, 2], dims=("dim_without_coord",))
  y = pm.Normal("y", x.sum(), dims=("dim_without_coord",))

We used to allow this also from RVs in the past but reverted in #6112
I don't see a fundamental difference between the two cases, and in that PR I just missed this.

I would suggest we remove this functionality because it adds quite some complexity in the Model class, including fancy checks to see if a Data variable defined from dims without coords of another Data variable is being resized before the original one (but after is fine?):

def test_set_data_warns_on_resize_of_dims_defined_by_other_mutabledata():
with pm.Model() as pmodel:
pm.MutableData("m1", [1, 2], dims="mutable")
pm.MutableData("m2", [3, 4], dims="mutable")
# Resizing the non-defining variable first gives a warning
with pytest.warns(ShapeWarning, match="by another variable"):
pmodel.set_data("m2", [4, 5, 6])
pmodel.set_data("m1", [1, 2, 3])
# Resizing the definint variable first is silent
with warnings.catch_warnings():
warnings.simplefilter("error")
pmodel.set_data("m1", [1, 2])
pmodel.set_data("m2", [3, 4])

(The unawareness) of this option has also led to bugs that were only patched recently: #6882

@ricardoV94
Copy link
Member Author

ricardoV94 commented Jun 27, 2024

This led to another bug in #7376

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant