Skip to content

Commit

Permalink
fixed test failing for log2 and log10 (due to floating point inprecis…
Browse files Browse the repository at this point in the history
…ion in the graph)
  • Loading branch information
Luke LB committed Sep 4, 2023
1 parent 9412b39 commit a912b20
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/logprob/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,13 @@ def test_special_log_exp_transforms(transform):
logp_test = logp(transformed_rv, vv)
logp_ref = logp(ref_transformed_rv, vv)

assert equal_computations([logp_test], [logp_ref])
if transform in ["log2", "log10"]:
# in the cases of log2 and log10 floating point inprecision causes failure
# from equal_computations so evaluate logp and check all close instead
vv_test = np.array(0.25)
np.testing.assert_allclose(logp_ref.eval({vv: vv_test}), logp_test.eval({vv: vv_test}))
else:
assert equal_computations([logp_test], [logp_ref])


@pytest.mark.parametrize(
Expand Down

0 comments on commit a912b20

Please sign in to comment.