From 8735ce5ad89826e4e953becc5a471e56c7a45b79 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Tue, 12 Jan 2021 23:25:42 -0600 Subject: [PATCH 1/3] Remove redundant test --- tests/test_probability.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_probability.py b/tests/test_probability.py index 1a26d94f72..07507549de 100644 --- a/tests/test_probability.py +++ b/tests/test_probability.py @@ -72,9 +72,6 @@ def test_independent(backend): assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0] == tb.tolist( result ) - assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0] == tb.tolist( - result - ) def test_simultaneous_list_ducktype(): From ebafa43d72ea6c962b3983a7b6cbfccf9f19be8c Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Tue, 12 Jan 2021 23:28:48 -0600 Subject: [PATCH 2/3] Use allclose with tolerance of 1e-12 --- tests/test_probability.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_probability.py b/tests/test_probability.py index 07507549de..ed95444eb9 100644 --- a/tests/test_probability.py +++ b/tests/test_probability.py @@ -69,8 +69,10 @@ def test_independent(backend): p1 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0)) p2 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(3.0)) - assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0] == tb.tolist( - result + assert np.allclose( + tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2]))[0], + tb.tolist(result), + atol=1e-12, ) From 397a5d7b064a35f53824b3d4887ee479e012f12e Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Tue, 12 Jan 2021 23:33:13 -0600 Subject: [PATCH 3/3] Use everywhere for saftey --- tests/test_probability.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_probability.py b/tests/test_probability.py index ed95444eb9..82bf0b9f26 100644 --- a/tests/test_probability.py +++ b/tests/test_probability.py @@ -56,8 +56,10 @@ def test_joint(backend): tb, _ = backend p1 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(2.0)) p2 = probability.Poisson(tb.astensor([10.0])).log_prob(tb.astensor(3.0)) - assert tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2])) == tb.tolist( - p1 + p2 + assert np.allclose( + tb.tolist(probability.Simultaneous._joint_logpdf([p1, p2])), + tb.tolist(p1 + p2), + atol=1e-12, )