aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/lib/grow_factor.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lib/grow_factor.py')
-rw-r--r--test/functional/lib/grow_factor.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/functional/lib/grow_factor.py b/test/functional/lib/grow_factor.py
new file mode 100644
index 000000000..486a186e8
--- /dev/null
+++ b/test/functional/lib/grow_factor.py
@@ -0,0 +1,32 @@
+from robot.libraries.BuiltIn import BuiltIn
+
+def Apply_Grow_Factor(grow_factor, max_limit):
+ grow_factor = float(grow_factor)
+ max_limit = float(max_limit)
+ expected_result = {}
+ res = BuiltIn().get_variable_value("${SCAN_RESULT}")
+
+ for sym, p in res["symbols"].items():
+ expected_result[sym] = p["score"]
+
+ if grow_factor <= 1.0:
+ return expected_result
+
+ if max_limit <= 0:
+ return expected_result
+
+ final_grow_factor = grow_factor
+ mult = grow_factor - 1.0
+ for sym, p in res["symbols"].items():
+ if p["score"] <= 0:
+ continue
+ mult *= round(p["score"] / max_limit, 2)
+ final_grow_factor *= round(1.0 + mult, 2)
+
+ if final_grow_factor <= 1.0:
+ return expected_result
+
+ for sym, p in res["symbols"].items():
+ if p["score"] <= 0:
+ continue
+ expected_result[sym] = round(p["score"] * final_grow_factor, 2)