aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/lib/grow_factor.py
blob: 486a186e82bf32b0290034188c7c7fd239ad09d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)