예제 #1
0
def test_getting_pmf(data, probs):
    trace = Trace(data)
    pmf = trace.pmf()
    assert set(pmf.keys()) == set(probs.keys())

    estimated, expected = [], []
    for v, p in probs.items():
        estimated.append(pmf[v])
        expected.append(p)
    np.testing.assert_almost_equal(estimated, expected)
예제 #2
0
def test_getting_pmf_for_empty_trace_raises_error():
    trace = Trace()
    with pytest.raises(ValueError) as excinfo:
        trace.pmf()
    assert 'expected non-empty values' in str(excinfo.value).lower()