[cig-commits] [commit] pull_39: tests: better float comparisons (d0894c8)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Mon Dec 8 12:30:21 PST 2014


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

On branch  : pull_39
Link       : https://github.com/geodynamics/burnman/compare/0000000000000000000000000000000000000000...ac2c35dff40d9f0fb90b442d0086964ebe5d5976

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

commit d0894c891cc5ca09cfdacfb8600aabb1ed052d6c
Author: Timo Heister <timo.heister at gmail.com>
Date:   Mon Dec 8 15:27:05 2014 -0500

    tests: better float comparisons


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

d0894c891cc5ca09cfdacfb8600aabb1ed052d6c
 tests/util.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tests/util.py b/tests/util.py
index 342cb6b..7daa2a6 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -1,8 +1,20 @@
 import unittest
 
 class BurnManTest(unittest.TestCase):
+    def assertFloatEqual(self,a,b):
+        self.assertAlmostEqual(a,b,delta=b*1e-5)
+
     def assertArraysAlmostEqual(self, a, b):
         self.assertEqual(len(a), len(b))
         for (i1, i2) in zip(a, b):
-            self.assertAlmostEqual(i1, i2)
+            self.assertFloatEqual(i1, i2)
+
+
+class Huh(BurnManTest):
+    def test(self):
+        self.assertFloatEqual(5200.01, 5200.015)
+
+if __name__ == '__main__':
+    unittest.main()
+
         



More information about the CIG-COMMITS mailing list