From dbc01705ccf768bca7a1eedfdc04c052e66939fa Mon Sep 17 00:00:00 2001 From: Nathan Weinberg Date: Tue, 19 Mar 2024 14:01:20 -0400 Subject: [PATCH] Changes from session with Mehul --- src/touchstone/decision_maker/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/touchstone/decision_maker/__init__.py b/src/touchstone/decision_maker/__init__.py index 2879cad..8c69dd2 100644 --- a/src/touchstone/decision_maker/__init__.py +++ b/src/touchstone/decision_maker/__init__.py @@ -29,19 +29,23 @@ def _compare(self, input_dict, compare_dict): # baseline value is the current value plus the tolerancy base_val = input_dict[self.baseline_uuid] + input_dict[self.baseline_uuid] * self.tolerancy / 100 for u, v in input_dict.items(): + # skip input_dict values that are part of the baseline uuid (no comparison to self) if u == self.baseline_uuid: continue try: metric_percent = v * 100 / input_dict[self.baseline_uuid] - # ZeroDivisionError means baseline value was 0, no comparison to be made here except ZeroDivisionError: - result = "Pass" - deviation = 0 - pass - else: + # both values are 0 + if (v == 0) and (input_dict[self.baseline_uuid] == 0): + metric_percent = 100 + # just baseline value is 0 + else: + metric_percent = 0 + finally: # If percentage is greater than 100, sustract 100 from it else substract it from 100 deviation = metric_percent - 100 if metric_percent > 100 else 100 - metric_percent deviation = -deviation if v < input_dict[self.baseline_uuid] else deviation + print(f"deviation is {deviation}") if (self.tolerancy >= 0 and v > base_val) or (self.tolerancy < 0 and v < base_val): result = "Fail" self.passed = False