check for keys leftover after pruning so marginalization works correctly

release/4.3a0
Varun Agrawal 2025-01-26 10:16:25 -05:00
parent 4d9f27cb28
commit fe880826ac
1 changed files with 3 additions and 1 deletions

View File

@ -66,7 +66,9 @@ HybridBayesNet HybridBayesNet::prune(
pruned.prune(maxNrLeaves);
DiscreteValues deadModesValues;
if (deadModeThreshold.has_value()) {
// If we have a dead mode threshold and discrete variables left after pruning,
// then we run dead mode removal.
if (deadModeThreshold.has_value() && pruned.keys().size() > 0) {
DiscreteMarginals marginals(DiscreteFactorGraph{pruned});
for (auto dkey : pruned.discreteKeys()) {
Vector probabilities = marginals.marginalProbabilities(dkey);