Skip to content

Commit

Permalink
Remove error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dellaert committed Sep 26, 2024
1 parent 69b1313 commit 83fae8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
9 changes: 2 additions & 7 deletions gtsam/hybrid/HybridGaussianConditional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ HybridGaussianConditional::ConstructorHelper::ConstructorHelper(
[&](const GaussianConditional::shared_ptr &c) -> GaussianFactorValuePair {
double value = 0.0;
if (c) {
KeyVector cf(c->frontals().begin(), c->frontals().end());
KeyVector cp(c->parents().begin(), c->parents().end());
if (frontals.empty()) {
frontals = cf;
parents = cp;
} else if (cf != frontals || cp != parents) {
throw std::invalid_argument(
"All conditionals must have the same frontals and parents");
frontals = KeyVector(c->frontals().begin(), c->frontals().end());
parents = KeyVector(c->parents().begin(), c->parents().end());
}
value = c->negLogConstant();
negLogConstant = std::min(negLogConstant, value);
Expand Down
17 changes: 5 additions & 12 deletions gtsam/hybrid/HybridGaussianFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ HybridGaussianFactor::ConstructorHelper::ConstructorHelper(
: discreteKeys({discreteKey}) {
// Extract continuous keys from the first non-null factor
for (const auto &factor : factors) {
if (!factor) continue; // Skip null factors
if (continuousKeys.empty()) {
if (factor && continuousKeys.empty()) {
continuousKeys = factor->keys();
} else if (factor->keys() != continuousKeys) {
throw std::invalid_argument("All factors must have the same keys");
break;
}
}

Expand All @@ -95,11 +93,9 @@ HybridGaussianFactor::ConstructorHelper::ConstructorHelper(
: discreteKeys({discreteKey}) {
// Extract continuous keys from the first non-null factor
for (const auto &pair : factorPairs) {
if (!pair.first) continue; // Skip null factors
if (continuousKeys.empty()) {
if (pair.first && continuousKeys.empty()) {
continuousKeys = pair.first->keys();
} else if (pair.first->keys() != continuousKeys) {
throw std::invalid_argument("All factors must have the same keys");
break;
}
}

Expand All @@ -113,11 +109,8 @@ HybridGaussianFactor::ConstructorHelper::ConstructorHelper(
: discreteKeys(discreteKeys) {
// Extract continuous keys from the first non-null factor
factorPairs.visit([&](const GaussianFactorValuePair &pair) {
if (!pair.first) return; // Skip null factors
if (continuousKeys.empty()) {
if (pair.first && continuousKeys.empty()) {
continuousKeys = pair.first->keys();
} else if (pair.first->keys() != continuousKeys) {
throw std::invalid_argument("All factors must have the same keys");
}
});

Expand Down

0 comments on commit 83fae8e

Please sign in to comment.