Skip to content

Commit bfc9e12

Browse files
ricardoV94twiecki
authored andcommitted
Test that missing values work as expected in distribution with vector parameters
1 parent 4a7916a commit bfc9e12

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pymc/tests/test_missing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import numpy as np
1717
import pandas as pd
1818
import pytest
19+
import scipy.stats
1920

2021
from numpy import array, ma
2122

@@ -188,3 +189,21 @@ def test_missing_multivariate():
188189
# m_miss.logp({"x_missing_simplex__": inp_vals}),
189190
# m_unobs.logp_nojac({"x_simplex__": inp_vals}) * 2,
190191
# )
192+
193+
194+
def test_missing_vector_parameter():
195+
with Model() as m:
196+
x = Normal(
197+
"x",
198+
np.array([-10, 10]),
199+
0.1,
200+
observed=np.array([[np.nan, 10], [-10, np.nan], [np.nan, np.nan]]),
201+
)
202+
x_draws = x.eval()
203+
assert x_draws.shape == (3, 2)
204+
assert np.all(x_draws[:, 0] < 0)
205+
assert np.all(x_draws[:, 1] > 0)
206+
assert np.isclose(
207+
m.logp({"x_missing": np.array([-10, 10, -10, 10])}),
208+
scipy.stats.norm(scale=0.1).logpdf(0) * 6,
209+
)

0 commit comments

Comments
 (0)