Fix python tests
parent
f9b14893c8
commit
e3c98b0faf
|
@ -79,7 +79,7 @@ class TestDiscreteBayesNet(GtsamTestCase):
|
||||||
self.gtsamAssertEquals(chordal.at(7), expected2)
|
self.gtsamAssertEquals(chordal.at(7), expected2)
|
||||||
|
|
||||||
# solve
|
# solve
|
||||||
actualMPE = chordal.optimize()
|
actualMPE = fg.optimize()
|
||||||
expectedMPE = DiscreteValues()
|
expectedMPE = DiscreteValues()
|
||||||
for key in [Asia, Dyspnea, XRay, Tuberculosis, Smoking, Either, LungCancer, Bronchitis]:
|
for key in [Asia, Dyspnea, XRay, Tuberculosis, Smoking, Either, LungCancer, Bronchitis]:
|
||||||
expectedMPE[key[0]] = 0
|
expectedMPE[key[0]] = 0
|
||||||
|
@ -94,8 +94,7 @@ class TestDiscreteBayesNet(GtsamTestCase):
|
||||||
fg.add(Dyspnea, "0 1")
|
fg.add(Dyspnea, "0 1")
|
||||||
|
|
||||||
# solve again, now with evidence
|
# solve again, now with evidence
|
||||||
chordal2 = fg.eliminateSequential(ordering)
|
actualMPE2 = fg.optimize()
|
||||||
actualMPE2 = chordal2.optimize()
|
|
||||||
expectedMPE2 = DiscreteValues()
|
expectedMPE2 = DiscreteValues()
|
||||||
for key in [XRay, Tuberculosis, Either, LungCancer]:
|
for key in [XRay, Tuberculosis, Either, LungCancer]:
|
||||||
expectedMPE2[key[0]] = 0
|
expectedMPE2[key[0]] = 0
|
||||||
|
@ -105,6 +104,7 @@ class TestDiscreteBayesNet(GtsamTestCase):
|
||||||
list(expectedMPE2.items()))
|
list(expectedMPE2.items()))
|
||||||
|
|
||||||
# now sample from it
|
# now sample from it
|
||||||
|
chordal2 = fg.eliminateSequential(ordering)
|
||||||
actualSample = chordal2.sample()
|
actualSample = chordal2.sample()
|
||||||
self.assertEqual(len(actualSample), 8)
|
self.assertEqual(len(actualSample), 8)
|
||||||
|
|
||||||
|
@ -122,10 +122,6 @@ class TestDiscreteBayesNet(GtsamTestCase):
|
||||||
for key in [Asia, Smoking]:
|
for key in [Asia, Smoking]:
|
||||||
given[key[0]] = 0
|
given[key[0]] = 0
|
||||||
|
|
||||||
# Now optimize fragment:
|
|
||||||
actual = fragment.optimize(given)
|
|
||||||
self.assertEqual(len(actual), 5)
|
|
||||||
|
|
||||||
# Now sample from fragment:
|
# Now sample from fragment:
|
||||||
actual = fragment.sample(given)
|
actual = fragment.sample(given)
|
||||||
self.assertEqual(len(actual), 5)
|
self.assertEqual(len(actual), 5)
|
||||||
|
|
Loading…
Reference in New Issue