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:
+4
-1
@@ -597,7 +597,10 @@ class RExpr:
|
|||||||
|
|
||||||
def eval(self, fields={}):
|
def eval(self, fields={}):
|
||||||
v = self.a.eval(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')
|
@func('total')
|
||||||
class Total(Expr):
|
class Total(Expr):
|
||||||
|
|||||||
Reference in New Issue
Block a user