Skip to content

Commit a44f739

Browse files
Add regression test for issue pymc-devs#5043
1 parent 595e164 commit a44f739

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

pymc/tests/test_idata_conversion.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212

1313
import pymc as pm
1414

15-
from pymc.backends.arviz import predictions_to_inference_data, to_inference_data
15+
from pymc.backends.arviz import (
16+
InferenceDataConverter,
17+
predictions_to_inference_data,
18+
to_inference_data,
19+
)
1620

1721

1822
@pytest.fixture(scope="module")
@@ -598,6 +602,25 @@ def test_constant_data_coords_issue_5046(self):
598602
for dname, cvals in coords.items():
599603
np.testing.assert_array_equal(ds[dname].values, cvals)
600604

605+
def test_issue_5043_autoconvert_coord_values(self):
606+
coords = {
607+
"city": ("Bonn", "Berlin"),
608+
}
609+
with pm.Model(coords=coords) as pmodel:
610+
assert isinstance(pmodel.coords["city"], tuple)
611+
pm.Normal("x", dims="city")
612+
mtrace = pm.sample(
613+
return_inferencedata=False,
614+
compute_convergence_checks=False,
615+
step=pm.Metropolis(),
616+
cores=1,
617+
tune=7,
618+
draws=15,
619+
)
620+
converter = InferenceDataConverter(trace=mtrace)
621+
with pytest.raises(ValueError, match="same length as the number of data dimensions"):
622+
converter.to_inference_data()
623+
601624

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

0 commit comments

Comments
 (0)