[cig-commits] [commit] master: fix assertFloatEqual and run all tests (dd0fb1c)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri Dec 12 14:27:17 PST 2014


Repository : https://github.com/geodynamics/burnman

On branch  : master
Link       : https://github.com/geodynamics/burnman/compare/6f75d3766c3c8e3bf6599b894e7bbe2993f57419...e7f78ff83a8092bc07fea4398232e73406e7cbbb

>---------------------------------------------------------------

commit dd0fb1ce5415c93d70fe01c9552499e3bb9952cf
Author: Timo Heister <timo.heister at gmail.com>
Date:   Fri Dec 12 14:24:33 2014 -0800

    fix assertFloatEqual and run all tests


>---------------------------------------------------------------

dd0fb1ce5415c93d70fe01c9552499e3bb9952cf
 tests/tests.py | 3 ++-
 tests/util.py  | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/tests.py b/tests/tests.py
index d51fc37..e847bda 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -1,5 +1,5 @@
 import unittest
-from util import BurnManTest
+from util import *
 from test_vrh import *
 from test_spin import *
 from test_composite import *
@@ -9,6 +9,7 @@ from test_eos import *
 from test_debye import *
 from test_solidsolution import *
 
+
 import os, sys
 sys.path.insert(1,os.path.abspath('..'))
 
diff --git a/tests/util.py b/tests/util.py
index 7daa2a6..12e041d 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -2,7 +2,7 @@ import unittest
 
 class BurnManTest(unittest.TestCase):
     def assertFloatEqual(self,a,b):
-        self.assertAlmostEqual(a,b,delta=b*1e-5)
+        self.assertAlmostEqual(a,b,delta=max(1e-16,max(abs(a),abs(b))*1e-5))
 
     def assertArraysAlmostEqual(self, a, b):
         self.assertEqual(len(a), len(b))
@@ -14,6 +14,9 @@ class Huh(BurnManTest):
     def test(self):
         self.assertFloatEqual(5200.01, 5200.015)
 
+    def test_to_zero(self):
+        self.assertFloatEqual(0, 1e-20)
+
 if __name__ == '__main__':
     unittest.main()
 



More information about the CIG-COMMITS mailing list