added a check if denominator is zero

This commit is contained in:
Jayendra 2023-01-01 16:16:15 +05:30
parent 326ae0cd88
commit 1dd96577b2
1 changed files with 11 additions and 8 deletions

View File

@ -269,6 +269,9 @@ class ApproxMapping(ApproxBase):
max_abs_diff = max( max_abs_diff = max(
max_abs_diff, abs(approx_value.expected - other_value) max_abs_diff, abs(approx_value.expected - other_value)
) )
if approx_value.expected == 0.0:
max_rel_diff = math.inf
else:
max_rel_diff = max( max_rel_diff = max(
max_rel_diff, max_rel_diff,
abs((approx_value.expected - other_value) / approx_value.expected), abs((approx_value.expected - other_value) / approx_value.expected),