Skip to content

Commit fbcce93

Browse files
Disallow "__sample__" as a dimension name
Co-authored-by: Thomas Wiecki <[email protected]>
1 parent 9ab831d commit fbcce93

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pymc3/model.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -959,17 +959,18 @@ def add_coord(
959959
----------
960960
name : str
961961
Name of the dimension.
962-
Forbidden: {"chain", "draw"}
962+
Forbidden: {"chain", "draw", "__sample__"}
963963
values : optional, array-like
964964
Coordinate values or ``None`` (for auto-numbering).
965965
If ``None`` is passed, a ``length`` must be specified.
966966
length : optional, scalar
967967
A symbolic scalar of the dimensions length.
968968
Defaults to ``aesara.shared(len(values))``.
969969
"""
970-
if name in {"draw", "chain"}:
970+
if name in {"draw", "chain", "__sample__"}:
971971
raise ValueError(
972-
"Dimensions can not be named `draw` or `chain`, as they are reserved for the sampler's outputs."
972+
"Dimensions can not be named `draw`, `chain` or `__sample__`, "
973+
"as those are reserved for use in `InferenceData`."
973974
)
974975
if values is None and length is None:
975976
raise ValueError(
@@ -981,7 +982,7 @@ def add_coord(
981982
)
982983
if name in self.coords:
983984
if not values.equals(self.coords[name]):
984-
raise ValueError("Duplicate and incompatiple coordinate: %s." % name)
985+
raise ValueError(f"Duplicate and incompatiple coordinate: {name}.")
985986
else:
986987
self._coords[name] = values
987988
self._dim_lengths[name] = length or aesara.shared(len(values))

pymc3/tests/test_sampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def test_return_inferencedata(self, monkeypatch):
213213
return_inferencedata=True,
214214
discard_tuned_samples=True,
215215
idata_kwargs={"prior": prior},
216-
random_seed=-1
216+
random_seed=-1,
217217
)
218218
assert "prior" in result
219219
assert isinstance(result, InferenceData)

0 commit comments

Comments
 (0)