Skip to content

Commit

Permalink
Do not issue warning when default transform of Mixture is None
Browse files Browse the repository at this point in the history
Also fixes typo in warning message
  • Loading branch information
ricardoV94 committed Jun 2, 2022
1 parent db5c87e commit 42e3745
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pymc/distributions/mixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def marginal_mixture_default_transform(op, rv):
def transform_warning():
warnings.warn(
f"No safe default transform found for Mixture distribution {rv}. This can "
"happen when compoments have different supports or default transforms.\n"
"happen when components have different supports or default transforms.\n"
"If appropriate, you can specify a custom transform for more efficient sampling.",
MixtureTransformWarning,
stacklevel=2,
Expand All @@ -463,6 +463,9 @@ def transform_warning():

default_transform = default_transforms[0]

if default_transform is None:
return None

if not isinstance(default_transform, allowed_default_mixture_transforms):
transform_warning()
return None
Expand Down
6 changes: 6 additions & 0 deletions pymc/tests/test_mixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,3 +1322,9 @@ def test_warning(self):
with pytest.warns(None) as rec:
Mixture("mix5", w=[0.5, 0.5], comp_dists=comp_dists, observed=1)
assert not rec

# Case where the appropriate default transform is None
comp_dists = [Normal.dist(), Normal.dist()]
with pytest.warns(None) as rec:
Mixture("mix6", w=[0.5, 0.5], comp_dists=comp_dists)
assert not rec

0 comments on commit 42e3745

Please sign in to comment.