From 895998268694d16fa61224481adab9fb3123cc04 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 14 Jun 2023 15:23:14 -0400 Subject: [PATCH] remove extra calls to Unique --- gtsam/discrete/DecisionTree-inl.h | 5 +++-- gtsam/discrete/tests/testDiscreteFactorGraph.cpp | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index 2f36007a9..8dc19ea21 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -544,7 +544,7 @@ namespace gtsam { template template DecisionTree::DecisionTree( Iterator begin, Iterator end, const L& label) { - root_ = Choice::Unique(compose(begin, end, label)); + root_ = compose(begin, end, label); } /****************************************************************************/ @@ -552,7 +552,7 @@ namespace gtsam { DecisionTree::DecisionTree(const L& label, const DecisionTree& f0, const DecisionTree& f1) { const std::vector functions{f0, f1}; - root_ = Choice::Unique(compose(functions.begin(), functions.end(), label)); + root_ = compose(functions.begin(), functions.end(), label); } /****************************************************************************/ @@ -603,6 +603,7 @@ namespace gtsam { auto choiceOnLabel = std::make_shared(label, end - begin); for (Iterator it = begin; it != end; it++) choiceOnLabel->push_back(it->root_); + // If no reordering, no need to call Choice::Unique return choiceOnLabel; } else { // Set up a new choice on the highest label diff --git a/gtsam/discrete/tests/testDiscreteFactorGraph.cpp b/gtsam/discrete/tests/testDiscreteFactorGraph.cpp index f148cf1d8..6752dbd4a 100644 --- a/gtsam/discrete/tests/testDiscreteFactorGraph.cpp +++ b/gtsam/discrete/tests/testDiscreteFactorGraph.cpp @@ -400,7 +400,6 @@ factor 1: f[ (m0,2), (m1,2), (m2,2), (m3,2), ] 1, 1, 1, 1, 0.015366387, 0.0094115739, 1, 1, 1, 1, 1, 1, 0.015366387, 0.0094115652, 0.015365663, 0.009321081}; DecisionTreeFactor f1(d1, p1); - DecisionTree dt1(d1, p1); DiscreteFactorGraph dfg; dfg.add(f0);