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.
16 from gtsam
import (DecisionTreeFactor, DiscreteDistribution, DiscreteValues,
22 """Tests for DecisionTreeFactors."""
30 """Test whether we can construct a factor from floats."""
35 """Test whether we can enumerate the factor."""
36 actual = self.
factor.enumerate()
37 _, values = zip(*actual)
38 self.assertEqual(
list(values), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
41 """Test whether multiplication works with overloading."""
60 """Test whether we can call methods in python."""
65 self.assertIsInstance(self.
factor(values), float)
68 self.assertIsInstance(self.
factor.cardinality(self.
A[0]), int)
71 self.assertIsInstance(self.
factor / self.
factor, DecisionTreeFactor)
74 self.assertIsInstance(self.
factor.sum(1), DecisionTreeFactor)
78 ordering.push_back(self.
A[0])
79 self.assertIsInstance(self.
factor.sum(ordering), DecisionTreeFactor)
82 self.assertIsInstance(self.
factor.
max(1), DecisionTreeFactor)
85 """Test whether the _repr_markdown_ method."""
98 return "A" if x == 12
else "B"
100 actual = self.
factor._repr_markdown_(formatter)
101 self.assertEqual(actual, expected)
104 if __name__ ==
"__main__":