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:
@@ -597,6 +597,9 @@ class RExpr:
|
|||||||
|
|
||||||
def eval(self, fields={}):
|
def eval(self, fields={}):
|
||||||
v = self.a.eval(fields)
|
v = self.a.eval(fields)
|
||||||
|
if not float(v.b):
|
||||||
|
return RFloat(1)
|
||||||
|
else:
|
||||||
return RFloat(float(v.a) / float(v.b))
|
return RFloat(float(v.a) / float(v.b))
|
||||||
|
|
||||||
@func('total')
|
@func('total')
|
||||||
|
|||||||
Reference in New Issue
Block a user