scripts: csv.py: Fixed divide by zero in ratio

This now returns 1.0 if the total part of the fraction is 0.

There may be a better way to handle this, but the intention is for 0/0
to map to 100% for thing like code coverage (cov.py), test coverage
(test.py), etc.
This commit is contained in:
Christopher Haster
2024-11-11 18:17:03 -06:00
parent cc25b39926
commit d4c835ba89

View File

@@ -597,7 +597,10 @@ class RExpr:
def eval(self, fields={}):
v = self.a.eval(fields)
return RFloat(float(v.a) / float(v.b))
if not float(v.b):
return RFloat(1)
else:
return RFloat(float(v.a) / float(v.b))
@func('total')
class Total(Expr):