experiment with removing the constructor
parent
f4bf280047
commit
55dc3f5372
|
@ -523,19 +523,19 @@ namespace gtsam {
|
|||
root_ = create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
template<typename L, typename Y>
|
||||
DecisionTree<L, Y>::DecisionTree(const std::vector<LabelC>& labelCs,
|
||||
const std::string& table) {
|
||||
// Convert std::string to values of type Y
|
||||
std::vector<Y> ys;
|
||||
std::istringstream iss(table);
|
||||
copy(std::istream_iterator<Y>(iss), std::istream_iterator<Y>(),
|
||||
back_inserter(ys));
|
||||
// /****************************************************************************/
|
||||
// template<typename L, typename Y>
|
||||
// DecisionTree<L, Y>::DecisionTree(const std::vector<LabelC>& labelCs,
|
||||
// const std::string& table) {
|
||||
// // Convert std::string to values of type Y
|
||||
// std::vector<Y> ys;
|
||||
// std::istringstream iss(table);
|
||||
// copy(std::istream_iterator<Y>(iss), std::istream_iterator<Y>(),
|
||||
// back_inserter(ys));
|
||||
|
||||
// now call recursive Create
|
||||
root_ = create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
|
||||
}
|
||||
// // now call recursive Create
|
||||
// root_ = create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
|
||||
// }
|
||||
|
||||
/****************************************************************************/
|
||||
template<typename L, typename Y>
|
||||
|
|
|
@ -205,8 +205,8 @@ namespace gtsam {
|
|||
/** Create from keys and a corresponding vector of values */
|
||||
DecisionTree(const std::vector<LabelC>& labelCs, const std::vector<Y>& ys);
|
||||
|
||||
/** Create from keys and string table */
|
||||
DecisionTree(const std::vector<LabelC>& labelCs, const std::string& table);
|
||||
// /** Create from keys and string table */
|
||||
// DecisionTree(const std::vector<LabelC>& labelCs, const std::string& table);
|
||||
|
||||
/** Create DecisionTree from others */
|
||||
template<typename Iterator>
|
||||
|
|
|
@ -333,17 +333,17 @@ TEST(DecisionTree, Compose) {
|
|||
|
||||
// Create from string
|
||||
vector<DT::LabelC> keys{DT::LabelC(A, 2), DT::LabelC(B, 2)};
|
||||
DT f2(keys, "0 2 1 3");
|
||||
DT f2(keys, {0, 2, 1, 3});
|
||||
EXPECT(assert_equal(f2, f1, 1e-9));
|
||||
|
||||
// Put this AB tree together with another one
|
||||
DT f3(keys, "4 6 5 7");
|
||||
DT f3(keys, {4, 6, 5, 7});
|
||||
DT f4(C, f1, f3);
|
||||
DOT(f4);
|
||||
|
||||
// a bigger tree
|
||||
keys.push_back(DT::LabelC(C, 2));
|
||||
DT f5(keys, "0 4 2 6 1 5 3 7");
|
||||
DT f5(keys, {0, 4, 2, 6, 1, 5, 3, 7});
|
||||
EXPECT(assert_equal(f5, f4, 1e-9));
|
||||
DOT(f5);
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ TEST(DecisionTree, threshold) {
|
|||
// Create three level tree
|
||||
const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2),
|
||||
DT::LabelC("A", 2)};
|
||||
DT tree(keys, "0 1 2 3 4 5 6 7");
|
||||
DT tree(keys, {0, 1, 2, 3, 4, 5, 6, 7});
|
||||
|
||||
// Check number of leaves equal to zero
|
||||
auto count = [](const int& value, int count) {
|
||||
|
@ -536,10 +536,10 @@ TEST(DecisionTree, ApplyWithAssignment) {
|
|||
// Create three level tree
|
||||
const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2),
|
||||
DT::LabelC("A", 2)};
|
||||
DT tree(keys, "1 2 3 4 5 6 7 8");
|
||||
DT tree(keys, {1, 2, 3, 4, 5, 6, 7, 8});
|
||||
|
||||
DecisionTree<string, double> probTree(
|
||||
keys, "0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08");
|
||||
keys, {0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08});
|
||||
double threshold = 0.045;
|
||||
|
||||
// We test pruning one tree by indexing into another.
|
||||
|
@ -553,7 +553,7 @@ TEST(DecisionTree, ApplyWithAssignment) {
|
|||
};
|
||||
DT prunedTree = tree.apply(pruner);
|
||||
|
||||
DT expectedTree(keys, "0 0 0 0 5 6 7 8");
|
||||
DT expectedTree(keys, {0, 0, 0, 0, 5, 6, 7, 8});
|
||||
EXPECT(assert_equal(expectedTree, prunedTree));
|
||||
|
||||
size_t count = 0;
|
||||
|
|
|
@ -55,14 +55,6 @@ class GTSAM_EXPORT HybridGaussianProductFactor
|
|||
*/
|
||||
HybridGaussianProductFactor(Base&& tree) : Base(std::move(tree)) {}
|
||||
|
||||
/// Deleted constructor since we don't have istream operator for
|
||||
/// GaussianFactorGraphValuePair
|
||||
HybridGaussianProductFactor(const std::vector<DiscreteKey>& labelCs,
|
||||
const std::string& table) {
|
||||
throw std::runtime_error(
|
||||
"HybridGaussianProductFactor: No way to construct.");
|
||||
}
|
||||
|
||||
///@}
|
||||
|
||||
/// @name Operators
|
||||
|
|
Loading…
Reference in New Issue