Skip to content

Commit

Permalink
Relax a few tests due to a very small rounding difference (jmschrei#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Feb 15, 2020
1 parent 0f412a8 commit 9340b3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/test_bayes_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def test_exact_structure_learning():
for X, logp in zip(datasets, logps):
model = BayesianNetwork.from_samples(X, algorithm='exact')
model2 = BayesianNetwork.from_samples(X, algorithm='exact-dp')
assert_equal(model.log_probability(X).sum(), model2.log_probability(X).sum())
assert_almost_equal(model.log_probability(X).sum(), model2.log_probability(X).sum())
assert_almost_equal(model.log_probability(X).sum(), logp, 4)

def test_from_structure():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def test_distributions_normal_nan_log_probability():

def test_distributions_normal_underflow_log_probability():
d = NormalDistribution(5, 1e-10)
assert_almost_equal(d.log_probability(1e100), -4.9999999999999987e+219)
assert_almost_equal(d.log_probability(1e100), -4.9999999999999987e+219, delta=6.270570637641398e+203)


def test_distributions_normal_probability():
Expand Down Expand Up @@ -1452,4 +1452,4 @@ def test_distributions_cpt_random_sample():
'B', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'])

assert_array_equal(d.sample(n=20, random_state=5), x)
assert_raises(AssertionError, assert_array_equal, d.sample(n=10), x)
assert_raises(AssertionError, assert_array_equal, d.sample(n=10), x)
5 changes: 3 additions & 2 deletions tests/test_profile_hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from nose.tools import assert_equal
from nose.tools import assert_not_equal
from nose.tools import assert_raises
from nose.tools import assert_almost_equal
import random
import numpy as np
import json
Expand Down Expand Up @@ -237,7 +238,7 @@ def test_same_length_viterbi():
sequences = [ list(x) for x in [ 'ACT', 'GGC', 'GAT', 'ACC' ] ]

for seq, score in zip( sequences, scores ):
assert_equal( model.viterbi( seq )[0], score )
assert_almost_equal( model.viterbi( seq )[0], score )

assert_raises( ValueError, model.viterbi, list('XXX') )

Expand All @@ -251,7 +252,7 @@ def test_variable_length_viterbi():
'ACGTG', 'ATTT', 'TACCCTC', 'TGTCAACACT') ]

for seq, score in zip( sequences, scores ):
assert_equal( model.viterbi( seq )[0], score )
assert_almost_equal( model.viterbi( seq )[0], score )


@with_setup( setup, teardown )
Expand Down

0 comments on commit 9340b3f

Please sign in to comment.