Skip to content

Commit e933fea

Browse files
committed
👌 update error message
1 parent f753c6b commit e933fea

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pymc/distributions/distribution.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,11 @@ def __new__(cls, name, *args, **kwargs):
579579
kwargs.setdefault("class_name", name)
580580
if isinstance(kwargs.get("observed", None), dict):
581581
raise TypeError(
582-
"The observed parameter should be of type `pd.Series`, `np.array`, or `pm.Data`."
582+
"Since ``v4.0.0`` the ``observed`` parameter should be of type"
583+
" ``pd.Series``, ``np.array``, or ``pm.Data``."
584+
" Previous versions allowed passing distribution parameters as"
585+
" a dictionary in ``observed``, in the current version these "
586+
"parameters are positional arguments."
583587
)
584588
return super().__new__(cls, name, *args, **kwargs)
585589

pymc/tests/distributions/test_distribution.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,18 @@ def test_density_dist_with_random(self, size):
145145
random=lambda mu, rng=None, size=None: rng.normal(loc=mu, scale=1, size=size),
146146
observed=np.random.randn(100, *size),
147147
)
148-
149148
assert obs.eval().shape == (100,) + size
150149

151150
def test_density_dist_with_random_invalid_observed(self):
152151
with pytest.raises(
153152
TypeError,
154-
match="The observed parameter should be of type `pd.Series`, `np.array`, or `pm.Data`",
153+
match=(
154+
"Since ``v4.0.0`` the ``observed`` parameter should be of type"
155+
" ``pd.Series``, ``np.array``, or ``pm.Data``."
156+
" Previous versions allowed passing distribution parameters as"
157+
" a dictionary in ``observed``, in the current version these "
158+
"parameters are positional arguments."
159+
),
155160
):
156161
size = (3,)
157162
with pm.Model() as model:

0 commit comments

Comments
 (0)