2929
3030#include < iomanip>
3131
32- using std::vector;
33- using std::string;
3432using std::map;
33+ using std::string;
34+ using std::vector;
3535using namespace gtsam ;
3636
3737template <typename T>
@@ -54,7 +54,8 @@ struct CrazyDecisionTree : public DecisionTree<string, Crazy> {
5454 auto keyFormatter = [](const std::string& s) { return s; };
5555 auto valueFormatter = [](const Crazy& v) {
5656 std::stringstream ss;
57- ss << " {" << v.a << " ," << std::setw (4 ) << std::setprecision (2 ) << v.b << " }" ;
57+ ss << " {" << v.a << " ," << std::setw (4 ) << std::setprecision (2 ) << v.b
58+ << " }" ;
5859 return ss.str ();
5960 };
6061 DecisionTree<string, Crazy>::print (" " , keyFormatter, valueFormatter);
@@ -103,9 +104,7 @@ struct DT : public DecisionTree<string, int> {
103104 // / print to stdout
104105 void print (const std::string& s = " " ) const {
105106 auto keyFormatter = [](const std::string& s) { return s; };
106- auto valueFormatter = [](const int & v) {
107- return std::to_string (v);
108- };
107+ auto valueFormatter = [](const int & v) { return std::to_string (v); };
109108 std::cout << s;
110109 Base::print (" " , keyFormatter, valueFormatter);
111110 }
@@ -132,10 +131,10 @@ TEST(DecisionTree, ConstructorOrder) {
132131 string A (" A" ), B (" B" );
133132
134133 const std::vector<int > ys1 = {1 , 2 , 3 , 4 };
135- DT tree1 ({{B, 2 }, {A, 2 }}, ys1); // faster version, as B is "higher" than A!
134+ DT tree1 ({{B, 2 }, {A, 2 }}, ys1); // faster version, as B is "higher" than A!
136135
137136 const std::vector<int > ys2 = {1 , 3 , 2 , 4 };
138- DT tree2 ({{A, 2 }, {B, 2 }}, ys2); // slower version !
137+ DT tree2 ({{A, 2 }, {B, 2 }}, ys2); // slower version !
139138
140139 // Both trees will be the same, tree is order from high to low labels.
141140 // Choice(B)
@@ -266,7 +265,8 @@ TEST(DecisionTree, Example) {
266265}
267266
268267/* ************************************************************************** */
269- // Test that we can create two trees out of one, using a function that returns a pair.
268+ // Test that we can create two trees out of one, using a function that returns a
269+ // pair.
270270TEST (DecisionTree, Split) {
271271 // Create labels
272272 string A (" A" ), B (" B" );
@@ -276,11 +276,11 @@ TEST(DecisionTree, Split) {
276276
277277 // Define a function that returns an int/bool pair
278278 auto split_function = [](const int & value) -> std::pair<int , bool > {
279- return {value* 3 , value* 3 % 2 == 0 };
279+ return {value * 3 , value * 3 % 2 == 0 };
280280 };
281281
282282 // Split the original tree into two new trees
283- auto [la,lb] = original.split <int ,bool >(split_function);
283+ auto [la, lb] = original.split <int , bool >(split_function);
284284
285285 // Check the first resulting tree
286286 EXPECT_LONGS_EQUAL (3 , la (Assignment<string>{{A, 0 }, {B, 0 }}));
@@ -295,7 +295,6 @@ TEST(DecisionTree, Split) {
295295 EXPECT (lb (Assignment<string>{{A, 1 }, {B, 1 }}));
296296}
297297
298-
299298/* ************************************************************************** */
300299// Test that we can create a tree by modifying an rvalue.
301300TEST (DecisionTree, Consume) {
@@ -305,7 +304,7 @@ TEST(DecisionTree, Consume) {
305304 // Create a decision tree
306305 DT original (A, DT (B, 1 , 2 ), DT (B, 3 , 4 ));
307306
308- DT modified ([](int i){ return i* 2 ; }, std::move (original));
307+ DT modified ([](int i) { return i * 2 ; }, std::move (original));
309308
310309 // Check the first resulting tree
311310 EXPECT_LONGS_EQUAL (2 , modified (Assignment<string>{{A, 0 }, {B, 0 }}));
@@ -319,7 +318,7 @@ TEST(DecisionTree, Consume) {
319318
320319/* ************************************************************************** */
321320// test Conversion of values
322- bool bool_of_int (const int & y) { return y != 0 ; };
321+ bool bool_of_int (const int & y) { return y != 0 ; }
323322typedef DecisionTree<string, bool > StringBoolTree;
324323
325324TEST (DecisionTree, ConvertValuesOnly) {
@@ -333,7 +332,7 @@ TEST(DecisionTree, ConvertValuesOnly) {
333332 StringBoolTree f2 (f1, bool_of_int);
334333
335334 // Check a value
336- Assignment<string> x00 {{A, 0 }, {B, 0 }};
335+ Assignment<string> x00{{A, 0 }, {B, 0 }};
337336 EXPECT (!f2 (x00));
338337}
339338
0 commit comments