Skip to content

Commit b6c890e

Browse files
ricardoV94AlexAndorra
authored andcommitted
OrderedLogistic and OrderedProbit no longer subclass Distribution
This fixes a bug when auto-imputation takes place, in which case the logic to retrieve `p` wasn't valid. This will also show `p` as an input of the underlying Categorical in the graphviz.
1 parent 10cb019 commit b6c890e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/distributions/test_discrete.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import pymc as pm
3131

32+
from pymc import ImputationWarning
3233
from pymc.distributions.discrete import OrderedLogistic, OrderedProbit
3334
from pymc.logprob.basic import icdf, logcdf, logp
3435
from pymc.logprob.utils import ParameterValueError
@@ -877,7 +878,10 @@ def test_compute_p(self):
877878

878879
# Test it works with auto-imputation
879880
with pm.Model() as m:
880-
pm.OrderedLogistic("ol", cutpoints=np.array([-2, 0, 2]), eta=0, observed=[0, np.nan, 1])
881+
with pytest.warns(ImputationWarning):
882+
pm.OrderedLogistic(
883+
"ol", cutpoints=np.array([-2, 0, 2]), eta=0, observed=[0, np.nan, 1]
884+
)
881885
assert len(m.deterministics) == 2 # One from the auto-imputation, the other from compute_p
882886

883887

@@ -925,7 +929,8 @@ def test_compute_p(self):
925929

926930
# Test it works with auto-imputation
927931
with pm.Model() as m:
928-
pm.OrderedProbit(
929-
"op", cutpoints=np.array([-2, 0, 2]), eta=0, sigma=1, observed=[0, np.nan, 1]
930-
)
932+
with pytest.warns(ImputationWarning):
933+
pm.OrderedProbit(
934+
"op", cutpoints=np.array([-2, 0, 2]), eta=0, sigma=1, observed=[0, np.nan, 1]
935+
)
931936
assert len(m.deterministics) == 2 # One from the auto-imputation, the other from compute_p

0 commit comments

Comments
 (0)