[Cython] Fixed implementation of absolute error tolerances in unit tests

This commit is contained in:
Ray Speth 2012-10-10 18:25:26 +00:00
parent 5252c41a80
commit 7869bd09c3

View file

@ -1,9 +1,10 @@
import numpy as np
import unittest
class CanteraTest(unittest.TestCase):
def assertNear(self, a, b, rtol=1e-8, atol=1e-12, msg=None):
cmp = 2 * abs(a - b)/(abs(a) + abs(b) + atol)
cmp = 2 * abs(a - b)/(abs(a) + abs(b) + 2 * atol / rtol)
if cmp > rtol:
message = ('AssertNear: %.14g - %.14g = %.14g\n' % (a, b, a-b) +
'Relative error of %10e exceeds rtol = %10e' % (cmp, rtol))