From 0b1c00a915873cf486e8a011f22bcbcced16b5bb Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Mon, 4 Jan 2021 10:47:01 +0100
Subject: [PATCH] Throw error if column not found in NumericColumnModule

---
 torch_modules/src/NumericColumnModule.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/torch_modules/src/NumericColumnModule.cpp b/torch_modules/src/NumericColumnModule.cpp
index 8fb0ab3..21ea408 100644
--- a/torch_modules/src/NumericColumnModule.cpp
+++ b/torch_modules/src/NumericColumnModule.cpp
@@ -78,8 +78,11 @@ void NumericColumnModuleImpl::addToContext(std::vector<std::vector<long>> & cont
     {
       double res = 0.0;
       if (index >= 0)
-        try {res = std::stof(config.getAsFeature(column, index).get());}
+      {
+        auto value = config.getAsFeature(column, index).get();
+        try {res = std::stof(value);}
         catch (std::exception &) {res = defaultValue;}
+      }
 
       contextElement.emplace_back(0);
       std::memcpy(&contextElement.back(), &res, sizeof res);
-- 
GitLab