Skip to content

Commit

Permalink
fix empty keys case
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Jan 1, 2025
1 parent ffa40f7 commit ab47ade
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gtsam/discrete/TableFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ DecisionTreeFactor TableFactor::toDecisionTreeFactor() const {

// If no keys, then return empty DecisionTreeFactor
if (dkeys.size() == 0) {
return DecisionTreeFactor(dkeys, AlgebraicDecisionTree<Key>());
AlgebraicDecisionTree<Key> tree;
if (sparse_table_.size() != 0) {
tree = AlgebraicDecisionTree<Key>(sparse_table_.coeff(0));
}
return DecisionTreeFactor(dkeys, tree);
}

std::vector<double> table;
Expand Down

0 comments on commit ab47ade

Please sign in to comment.