Skip to content

Commit b3daa2d

Browse files
Don't replace local coords variable inside iterator
Closes #5046
1 parent 5ef8e44 commit b3daa2d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pymc/backends/arviz.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ def dict_to_dataset(
131131
for name, vals in data.items():
132132
vals = np.atleast_1d(vals)
133133
val_dims = dims.get(name)
134-
val_dims, coords = generate_dims_coords(vals.shape, name, dims=val_dims, coords=coords)
135-
coords = {key: xr.IndexVariable((key,), data=coords[key]) for key in val_dims}
136-
out_data[name] = xr.DataArray(vals, dims=val_dims, coords=coords)
134+
val_dims, crds = generate_dims_coords(vals.shape, name, dims=val_dims, coords=coords)
135+
crds = {key: xr.IndexVariable((key,), data=crds[key]) for key in val_dims}
136+
out_data[name] = xr.DataArray(vals, dims=val_dims, coords=crds)
137137
return xr.Dataset(data_vars=out_data, attrs=make_attrs(attrs=attrs, library=library))
138138

139139

pymc/tests/test_idata_conversion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,8 @@ def test_multivariate_observations(self):
568568
assert "direction" not in idata.log_likelihood.dims
569569
assert "direction" in idata.observed_data.dims
570570

571-
@pytest.mark.xfail(reason="Critical bug in dataset conversion.")
572571
def test_constant_data_coords_issue_5046(self):
573-
# For some reason only the first entry of the `dims` ends up in the dataset.
572+
"""This is a regression test against a bug where a local coords variable was overwritten."""
574573
dims = {
575574
"alpha": ["backwards"],
576575
"bravo": ["letters", "yesno"],

0 commit comments

Comments
 (0)