diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 7cd5b5d64c..1abc3e2315 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,6 +1,14 @@ # Release Notes -## PyMC 3.4 (unreleased) + +## PyMC 3.5 (Unreleaased) + + +### Fixes + +- Fixed `KeyError` raised when only subset of variables are specified to be recorded in the trace. + +## PyMC 3.4.1 (April 18 2018) ### New features diff --git a/pymc3/backends/report.py b/pymc3/backends/report.py index e97c7cfbc0..f2b81d8761 100644 --- a/pymc3/backends/report.py +++ b/pymc3/backends/report.py @@ -77,7 +77,8 @@ def _run_convergence_checks(self, trace, model): if is_transformed_name(rv_name): rv_name2 = get_untransformed_name(rv_name) rv_name = rv_name2 if rv_name2 in valid_name else rv_name - varnames.append(rv_name) + if rv_name in trace.varnames: + varnames.append(rv_name) self._effective_n = effective_n = diagnostics.effective_n(trace, varnames) self._gelman_rubin = gelman_rubin = diagnostics.gelman_rubin(trace, varnames) diff --git a/pymc3/tests/test_sampling.py b/pymc3/tests/test_sampling.py index 30362019c0..ef9d85a78f 100644 --- a/pymc3/tests/test_sampling.py +++ b/pymc3/tests/test_sampling.py @@ -140,6 +140,11 @@ def test_empty_model(): pm.sample() error.match('any free variables') +def test_partial_trace_sample(): + with pm.Model() as model: + a = pm.Normal('a', mu=0, sd=1) + b = pm.Normal('b', mu=0, sd=1) + trace = pm.sample(trace=[a]) @pytest.mark.xfail(condition=(theano.config.floatX == "float32"), reason="Fails on float32") class TestNamedSampling(SeededTest):