fix tests

release/4.3a0
Varun Agrawal 2023-07-17 12:47:19 -04:00
parent 3fe2682d93
commit 2f3fcff916
2 changed files with 3 additions and 34 deletions

View File

@ -25,6 +25,7 @@
#include <gtsam/base/serializationTestHelpers.h>
#include <gtsam/discrete/DecisionTree-inl.h>
#include <gtsam/discrete/Signature.h>
#include <gtsam/inference/Symbol.h>
#include <iomanip>
@ -531,38 +532,6 @@ TEST(DecisionTree, ApplyWithAssignment) {
EXPECT_LONGS_EQUAL(5, count);
}
/* ************************************************************************** */
// Test number of assignments.
TEST(DecisionTree, NrAssignments2) {
using gtsam::symbol_shorthand::M;
std::vector<double> probs = {0, 0, 1, 2};
/* Create the decision tree
Choice(m1)
0 Leaf 0.000000
1 Choice(m0)
1 0 Leaf 1.000000
1 1 Leaf 2.000000
*/
DiscreteKeys keys{{M(1), 2}, {M(0), 2}};
DecisionTree<Key, double> dt1(keys, probs);
EXPECT_LONGS_EQUAL(4, dt1.nrAssignments());
/* Create the DecisionTree
Choice(m1)
0 Choice(m0)
0 0 Leaf 0.000000
0 1 Leaf 1.000000
1 Choice(m0)
1 0 Leaf 0.000000
1 1 Leaf 2.000000
*/
DiscreteKeys keys2{{M(0), 2}, {M(1), 2}};
DecisionTree<Key, double> dt2(keys2, probs);
EXPECT_LONGS_EQUAL(4, dt2.nrAssignments());
}
/* ************************************************************************* */
int main() {
TestResult tr;

View File

@ -63,8 +63,8 @@ TEST(MixtureFactor, Printing) {
R"(Hybrid [x1 x2; 1]
MixtureFactor
Choice(1)
0 Leaf Nonlinear factor on 2 keys
1 Leaf Nonlinear factor on 2 keys
0 Leaf [1]Nonlinear factor on 2 keys
1 Leaf [1]Nonlinear factor on 2 keys
)";
EXPECT(assert_print_equal(expected, mixtureFactor));
}