Skip to content

Commit 5ef8e44

Browse files
Add test case for constant_data coords issue #5046
1 parent a3cc81c commit 5ef8e44

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pymc/tests/test_idata_conversion.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,37 @@ 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.")
572+
def test_constant_data_coords_issue_5046(self):
573+
# For some reason only the first entry of the `dims` ends up in the dataset.
574+
dims = {
575+
"alpha": ["backwards"],
576+
"bravo": ["letters", "yesno"],
577+
}
578+
coords = {
579+
"backwards": np.arange(17)[::-1],
580+
"letters": list("ABCDEFGHIJK"),
581+
"yesno": ["yes", "no"],
582+
}
583+
data = {
584+
name: np.random.uniform(size=[len(coords[dn]) for dn in dnames])
585+
for name, dnames in dims.items()
586+
}
587+
588+
for k in data:
589+
assert len(data[k].shape) == len(dims[k])
590+
591+
ds = pm.backends.arviz.dict_to_dataset(
592+
data=data,
593+
library=pm,
594+
coords=coords,
595+
dims=dims,
596+
default_dims=[],
597+
index_origin=0,
598+
)
599+
for dname, cvals in coords.items():
600+
np.testing.assert_array_equal(ds[dname].values, cvals)
601+
571602

572603
class TestPyMCWarmupHandling:
573604
@pytest.mark.parametrize("save_warmup", [False, True])

0 commit comments

Comments
 (0)