From 8abd2756ea895dbd0da4ab5246730533f27075ff Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 21 Aug 2024 04:19:44 -0400 Subject: [PATCH] throw error if invalid assignment --- gtsam/hybrid/GaussianMixture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gtsam/hybrid/GaussianMixture.cpp b/gtsam/hybrid/GaussianMixture.cpp index 1411ede8d..0a0332af8 100644 --- a/gtsam/hybrid/GaussianMixture.cpp +++ b/gtsam/hybrid/GaussianMixture.cpp @@ -346,9 +346,10 @@ double GaussianMixture::error(const HybridValues &values) const { } } - // The discrete assignment is not valid so we return 0.0 erorr. + // The discrete assignment is not valid so we throw an error. if (!valid_assignment) { - return 0.0; + throw std::runtime_error( + "Invalid discrete values in values. Not all discrete keys specified."); } // Directly index to get the conditional, no need to build the whole tree.