Skip to content

Commit 42e3745

Browse files
committed
Do not issue warning when default transform of Mixture is None
Also fixes typo in warning message
1 parent db5c87e commit 42e3745

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pymc/distributions/mixture.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def marginal_mixture_default_transform(op, rv):
444444
def transform_warning():
445445
warnings.warn(
446446
f"No safe default transform found for Mixture distribution {rv}. This can "
447-
"happen when compoments have different supports or default transforms.\n"
447+
"happen when components have different supports or default transforms.\n"
448448
"If appropriate, you can specify a custom transform for more efficient sampling.",
449449
MixtureTransformWarning,
450450
stacklevel=2,
@@ -463,6 +463,9 @@ def transform_warning():
463463

464464
default_transform = default_transforms[0]
465465

466+
if default_transform is None:
467+
return None
468+
466469
if not isinstance(default_transform, allowed_default_mixture_transforms):
467470
transform_warning()
468471
return None

pymc/tests/test_mixture.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,3 +1322,9 @@ def test_warning(self):
13221322
with pytest.warns(None) as rec:
13231323
Mixture("mix5", w=[0.5, 0.5], comp_dists=comp_dists, observed=1)
13241324
assert not rec
1325+
1326+
# Case where the appropriate default transform is None
1327+
comp_dists = [Normal.dist(), Normal.dist()]
1328+
with pytest.warns(None) as rec:
1329+
Mixture("mix6", w=[0.5, 0.5], comp_dists=comp_dists)
1330+
assert not rec

0 commit comments

Comments
 (0)