2 GTSAM Copyright 2010-2021, Georgia Tech Research Corporation,
3 Atlanta, Georgia 30332-0415
6 See LICENSE for the license information
8 Unit tests for DecisionTreeFactors.
18 from gtsam
import (DecisionTreeFactor, DiscreteDistribution, DiscreteValues,
23 """Tests for DecisionTreeFactors."""
31 """Test whether we can construct a factor from floats."""
36 """Test whether we can enumerate the factor."""
37 actual = self.
factor.enumerate()
38 _, values = zip(*actual)
39 self.assertEqual(
list(values), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
42 """Test whether multiplication works with overloading."""
61 """Test whether we can call methods in python."""
66 self.assertIsInstance(self.
factor(values), float)
69 self.assertIsInstance(self.
factor.cardinality(self.
A[0]), int)
72 self.assertIsInstance(self.
factor / self.
factor, DecisionTreeFactor)
75 self.assertIsInstance(self.
factor.sum(1), DecisionTreeFactor)
79 ordering.push_back(self.
A[0])
80 self.assertIsInstance(self.
factor.sum(ordering), DecisionTreeFactor)
83 self.assertIsInstance(self.
factor.
max(1), DecisionTreeFactor)
86 """Test whether the _repr_markdown_ method."""
99 return "A" if x == 12
else "B"
101 actual = self.
factor._repr_markdown_(formatter)
102 self.assertEqual(actual, expected)
105 if __name__ ==
"__main__":