From 6c0af57835ef03b5a23e4b7f763ee7147ac9583c Mon Sep 17 00:00:00 2001 From: Jonathan Vandermause Date: Fri, 1 Nov 2024 00:57:57 -0400 Subject: [PATCH 1/2] check size of n_added --- src/flare_pp/bffs/sparse_gp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/flare_pp/bffs/sparse_gp.cpp b/src/flare_pp/bffs/sparse_gp.cpp index 698ee6f0..74a1ad94 100644 --- a/src/flare_pp/bffs/sparse_gp.cpp +++ b/src/flare_pp/bffs/sparse_gp.cpp @@ -191,6 +191,8 @@ void SparseGP ::add_specific_environments(const Structure &structure, void SparseGP ::add_uncertain_environments(const Structure &structure, const std::vector &n_added) { + assert(n_added.size() == n_kernels && "n_added must have the same size as the number of kernels"); + initialize_sparse_descriptors(structure); // Compute cluster uncertainties. std::vector> sorted_indices = From 47431da892d3762d8bef25844d5ad06e12206994 Mon Sep 17 00:00:00 2001 From: Jonathan Vandermause Date: Fri, 1 Nov 2024 00:59:27 -0400 Subject: [PATCH 2/2] use runtime error instead --- src/flare_pp/bffs/sparse_gp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/flare_pp/bffs/sparse_gp.cpp b/src/flare_pp/bffs/sparse_gp.cpp index 74a1ad94..c713f7df 100644 --- a/src/flare_pp/bffs/sparse_gp.cpp +++ b/src/flare_pp/bffs/sparse_gp.cpp @@ -191,7 +191,9 @@ void SparseGP ::add_specific_environments(const Structure &structure, void SparseGP ::add_uncertain_environments(const Structure &structure, const std::vector &n_added) { - assert(n_added.size() == n_kernels && "n_added must have the same size as the number of kernels"); + if (n_added.size() != n_kernels) { + throw std::runtime_error("n_added must have the same size as the number of kernels"); + } initialize_sparse_descriptors(structure); // Compute cluster uncertainties.