From 04a3dd4e0c4ce9fb292250529678d88c0e0212da Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Sat, 14 Aug 2021 14:47:09 +0200 Subject: [PATCH] cap rates to a minimum of 0.1 With lower rates than 0.1, the algorithm to calculate the allowed kcal values can takes a very long time to run, and the plot also explodes in the y axis. Print a warning in that case, and cap the value to a minimum of 0.1. --- lib/nom/config.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/nom/config.rb b/lib/nom/config.rb index a5dfa92..b877831 100644 --- a/lib/nom/config.rb +++ b/lib/nom/config.rb @@ -45,6 +45,11 @@ def get key raise "Unknown configuration option '#{key}'" end + if key == "rate" and @config["rate"] < 0.1 + puts "Warning: rates smaller than 0.1 are not supported, capping to 0.1" + 0.1 + end + if @defaults[key][2] == Float v.to_f elsif @defaults[key][2] == Date