From 5ee4fe611a29134ced0df9159089374b0a25ba09 Mon Sep 17 00:00:00 2001
From: Thomas <purcell@fhi-berlin.mpg.de>
Date: Fri, 16 Apr 2021 09:21:47 +0200
Subject: [PATCH] Add option for InputParser to not need all lists defined in
 the input file

If a key is not in the file just return and empty vector
---
 src/inputs/InputParser.hpp         | 3 +++
 tests/exec_test/default/sisso.json | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/inputs/InputParser.hpp b/src/inputs/InputParser.hpp
index 73c64ae3..1b634595 100644
--- a/src/inputs/InputParser.hpp
+++ b/src/inputs/InputParser.hpp
@@ -118,6 +118,9 @@ template <typename T>
 std::vector<T> as_vector(pt::ptree const &pt, pt::ptree::key_type const &key)
 {
     std::vector<T> r;
+    if(pt.count(key) == 0)
+        return r;
+
     for (auto& item : pt.get_child(key))
         r.push_back(item.second.get_value<T>());
     return r;
diff --git a/tests/exec_test/default/sisso.json b/tests/exec_test/default/sisso.json
index 36a06148..48cf9c98 100644
--- a/tests/exec_test/default/sisso.json
+++ b/tests/exec_test/default/sisso.json
@@ -10,6 +10,5 @@
     "n_models_store": 1,
     "leave_out_inds": [0, 1, 2, 60, 61],
     "opset": ["add", "sub", "abs_diff", "mult", "div", "inv", "abs", "exp", "log", "sin", "cos", "sq", "cb", "six_pow", "sqrt", "cbrt", "neg_exp"],
-    "param_opset": [],
     "fix_intercept": false
 }
-- 
GitLab