Revert "experiment with removing the constructor"

This reverts commit 55dc3f5372.
release/4.3a0
Varun Agrawal 2024-10-09 13:37:55 -04:00
parent 55dc3f5372
commit 4d707e7cdd
4 changed files with 29 additions and 21 deletions

View File

@ -523,19 +523,19 @@ namespace gtsam {
root_ = create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end()); root_ = create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
} }
// /****************************************************************************/ /****************************************************************************/
// template<typename L, typename Y> template<typename L, typename Y>
// DecisionTree<L, Y>::DecisionTree(const std::vector<LabelC>& labelCs, DecisionTree<L, Y>::DecisionTree(const std::vector<LabelC>& labelCs,
// const std::string& table) { const std::string& table) {
// // Convert std::string to values of type Y // Convert std::string to values of type Y
// std::vector<Y> ys; std::vector<Y> ys;
// std::istringstream iss(table); std::istringstream iss(table);
// copy(std::istream_iterator<Y>(iss), std::istream_iterator<Y>(), copy(std::istream_iterator<Y>(iss), std::istream_iterator<Y>(),
// back_inserter(ys)); back_inserter(ys));
// // now call recursive Create // now call recursive Create
// root_ = create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end()); root_ = create(labelCs.begin(), labelCs.end(), ys.begin(), ys.end());
// } }
/****************************************************************************/ /****************************************************************************/
template<typename L, typename Y> template<typename L, typename Y>

View File

@ -205,8 +205,8 @@ namespace gtsam {
/** Create from keys and a corresponding vector of values */ /** Create from keys and a corresponding vector of values */
DecisionTree(const std::vector<LabelC>& labelCs, const std::vector<Y>& ys); DecisionTree(const std::vector<LabelC>& labelCs, const std::vector<Y>& ys);
// /** Create from keys and string table */ /** Create from keys and string table */
// DecisionTree(const std::vector<LabelC>& labelCs, const std::string& table); DecisionTree(const std::vector<LabelC>& labelCs, const std::string& table);
/** Create DecisionTree from others */ /** Create DecisionTree from others */
template<typename Iterator> template<typename Iterator>

View File

@ -333,17 +333,17 @@ TEST(DecisionTree, Compose) {
// Create from string // Create from string
vector<DT::LabelC> keys{DT::LabelC(A, 2), DT::LabelC(B, 2)}; 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)); EXPECT(assert_equal(f2, f1, 1e-9));
// Put this AB tree together with another one // 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); DT f4(C, f1, f3);
DOT(f4); DOT(f4);
// a bigger tree // a bigger tree
keys.push_back(DT::LabelC(C, 2)); 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)); EXPECT(assert_equal(f5, f4, 1e-9));
DOT(f5); DOT(f5);
} }
@ -508,7 +508,7 @@ TEST(DecisionTree, threshold) {
// Create three level tree // Create three level tree
const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2), const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2),
DT::LabelC("A", 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 // Check number of leaves equal to zero
auto count = [](const int& value, int count) { auto count = [](const int& value, int count) {
@ -536,10 +536,10 @@ TEST(DecisionTree, ApplyWithAssignment) {
// Create three level tree // Create three level tree
const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2), const vector<DT::LabelC> keys{DT::LabelC("C", 2), DT::LabelC("B", 2),
DT::LabelC("A", 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( 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; double threshold = 0.045;
// We test pruning one tree by indexing into another. // We test pruning one tree by indexing into another.
@ -553,7 +553,7 @@ TEST(DecisionTree, ApplyWithAssignment) {
}; };
DT prunedTree = tree.apply(pruner); 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)); EXPECT(assert_equal(expectedTree, prunedTree));
size_t count = 0; size_t count = 0;

View File

@ -55,6 +55,14 @@ class GTSAM_EXPORT HybridGaussianProductFactor
*/ */
HybridGaussianProductFactor(Base&& tree) : Base(std::move(tree)) {} 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 /// @name Operators