Fix formatting
parent
d0ff3ab97e
commit
9317e94452
|
@ -65,14 +65,15 @@ struct CrazyDecisionTree : public DecisionTree<string, Crazy> {
|
|||
|
||||
// traits
|
||||
namespace gtsam {
|
||||
template<> struct traits<CrazyDecisionTree> : public Testable<CrazyDecisionTree> {};
|
||||
}
|
||||
template <>
|
||||
struct traits<CrazyDecisionTree> : public Testable<CrazyDecisionTree> {};
|
||||
} // namespace gtsam
|
||||
|
||||
GTSAM_CONCEPT_TESTABLE_INST(CrazyDecisionTree)
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// Test string labels and int range
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
|
||||
struct DT : public DecisionTree<string, int> {
|
||||
using Base = DecisionTree<string, int>;
|
||||
|
@ -98,30 +99,21 @@ struct DT : public DecisionTree<string, int> {
|
|||
|
||||
// traits
|
||||
namespace gtsam {
|
||||
template<> struct traits<DT> : public Testable<DT> {};
|
||||
}
|
||||
template <>
|
||||
struct traits<DT> : public Testable<DT> {};
|
||||
} // namespace gtsam
|
||||
|
||||
GTSAM_CONCEPT_TESTABLE_INST(DT)
|
||||
|
||||
struct Ring {
|
||||
static inline int zero() {
|
||||
return 0;
|
||||
}
|
||||
static inline int one() {
|
||||
return 1;
|
||||
}
|
||||
static inline int id(const int& a) {
|
||||
return a;
|
||||
}
|
||||
static inline int add(const int& a, const int& b) {
|
||||
return a + b;
|
||||
}
|
||||
static inline int mul(const int& a, const int& b) {
|
||||
return a * b;
|
||||
}
|
||||
static inline int zero() { return 0; }
|
||||
static inline int one() { return 1; }
|
||||
static inline int id(const int& a) { return a; }
|
||||
static inline int add(const int& a, const int& b) { return a + b; }
|
||||
static inline int mul(const int& a, const int& b) { return a * b; }
|
||||
};
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// test DT
|
||||
TEST(DecisionTree, example) {
|
||||
// Create labels
|
||||
|
@ -228,7 +220,7 @@ TEST(DecisionTree, example) {
|
|||
DOT(acnotb);
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// test Conversion of values
|
||||
bool bool_of_int(const int& y) { return y != 0; };
|
||||
typedef DecisionTree<string, bool> StringBoolTree;
|
||||
|
@ -249,11 +241,9 @@ TEST(DecisionTree, ConvertValuesOnly) {
|
|||
EXPECT(!f2(x00));
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// test Conversion of both values and labels.
|
||||
enum Label {
|
||||
U, V, X, Y, Z
|
||||
};
|
||||
enum Label { U, V, X, Y, Z };
|
||||
typedef DecisionTree<Label, bool> LabelBoolTree;
|
||||
|
||||
TEST(DecisionTree, ConvertBoth) {
|
||||
|
@ -281,7 +271,7 @@ TEST(DecisionTree, ConvertBoth) {
|
|||
EXPECT(!f2(x11));
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// test Compose expansion
|
||||
TEST(DecisionTree, Compose) {
|
||||
// Create labels
|
||||
|
@ -308,7 +298,7 @@ TEST(DecisionTree, Compose) {
|
|||
DOT(f5);
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// Check we can create a decision tree of containers.
|
||||
TEST(DecisionTree, Containers) {
|
||||
using Container = std::vector<double>;
|
||||
|
@ -330,7 +320,7 @@ TEST(DecisionTree, Containers) {
|
|||
StringContainerTree converted(stringIntTree, container_of_int);
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// Test visit.
|
||||
TEST(DecisionTree, visit) {
|
||||
// Create small two-level tree
|
||||
|
@ -342,7 +332,7 @@ TEST(DecisionTree, visit) {
|
|||
EXPECT_DOUBLES_EQUAL(6.0, sum, 1e-9);
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// Test visit, with Choices argument.
|
||||
TEST(DecisionTree, visitWith) {
|
||||
// Create small two-level tree
|
||||
|
@ -354,7 +344,7 @@ TEST(DecisionTree, visitWith) {
|
|||
EXPECT_DOUBLES_EQUAL(6.0, sum, 1e-9);
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// Test fold.
|
||||
TEST(DecisionTree, fold) {
|
||||
// Create small two-level tree
|
||||
|
@ -365,7 +355,7 @@ TEST(DecisionTree, fold) {
|
|||
EXPECT_DOUBLES_EQUAL(6.0, sum, 1e-9);
|
||||
}
|
||||
|
||||
/* ******************************************************************************** */
|
||||
/* ************************************************************************** */
|
||||
// Test retrieving all labels.
|
||||
TEST(DecisionTree, labels) {
|
||||
// Create small two-level tree
|
||||
|
|
Loading…
Reference in New Issue