def percent_deviation(self):
expected = self.expected
if isinstance(expected, float):
expected = Decimal.from_float(expected)
else:
expected = Decimal(expected if expected else 0)
deviation = self.deviation
if isinstance(deviation, float):
deviation = Decimal.from_float(deviation)
else:
deviation = Decimal(deviation if deviation else 0)
if isnan(expected) or isnan(deviation):
return Decimal('NaN')
return deviation / expected if expected else Decimal(0) # % error calc.
评论列表
文章目录