Add check for zero denominator in approx (#10624)

Closes #10533
This commit is contained in:
Jay
2023-01-24 15:37:42 +05:30
committed by GitHub
parent 05eee78aaa
commit ca40380e99
3 changed files with 24 additions and 4 deletions

View File

@@ -269,10 +269,16 @@ class ApproxMapping(ApproxBase):
max_abs_diff = max(
max_abs_diff, abs(approx_value.expected - other_value)
)
max_rel_diff = max(
max_rel_diff,
abs((approx_value.expected - other_value) / approx_value.expected),
)
if approx_value.expected == 0.0:
max_rel_diff = math.inf
else:
max_rel_diff = max(
max_rel_diff,
abs(
(approx_value.expected - other_value)
/ approx_value.expected
),
)
different_ids.append(approx_key)
message_data = [