| 1 |
from robot.libraries.BuiltIn import BuiltIn |
| 2 |
|
| 3 |
def Apply_Grow_Factor(grow_factor, max_limit): |
| 4 |
grow_factor = float(grow_factor) |
| 5 |
max_limit = float(max_limit) |
| 6 |
expected_result = {} |
| 7 |
res = BuiltIn().get_variable_value("${SCAN_RESULT}") |
| 8 |
|
| 9 |
for sym, p in res["symbols"].items(): |
| 10 |
expected_result[sym] = p["score"] |
| 11 |
|
| 12 |
if grow_factor <= 1.0: |
| 13 |
return expected_result |
| 14 |
|
| 15 |
if max_limit <= 0: |
| 16 |
return expected_result |
| 17 |
|
| 18 |
final_grow_factor = grow_factor |
| 19 |
mult = grow_factor - 1.0 |
| 20 |
for sym, p in res["symbols"].items(): |
| 21 |
if p["score"] <= 0: |
| 22 |
continue |
| 23 |
mult *= round(p["score"] / max_limit, 2) |
| 24 |
final_grow_factor *= round(1.0 + mult, 2) |
| 25 |
|
| 26 |
if final_grow_factor <= 1.0: |
| 27 |
return expected_result |
| 28 |
|
| 29 |
for sym, p in res["symbols"].items(): |
| 30 |
if p["score"] <= 0: |
| 31 |
continue |
| 32 |
expected_result[sym] = round(p["score"] * final_grow_factor, 2) |