|
12 | 12 |
|
13 | 13 | import pymc as pm
|
14 | 14 |
|
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 | +) |
16 | 20 |
|
17 | 21 |
|
18 | 22 | @pytest.fixture(scope="module")
|
@@ -598,6 +602,25 @@ def test_constant_data_coords_issue_5046(self):
|
598 | 602 | for dname, cvals in coords.items():
|
599 | 603 | np.testing.assert_array_equal(ds[dname].values, cvals)
|
600 | 604 |
|
| 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 | + |
601 | 624 |
|
602 | 625 | class TestPyMCWarmupHandling:
|
603 | 626 | @pytest.mark.parametrize("save_warmup", [False, True])
|
|
0 commit comments