test_floating_point
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Sun, 11 Oct 2020 17:08:21 +0000 (18:08 +0100)
committerDrew Parsons <dparsons@debian.org>
Sun, 11 Oct 2020 17:08:21 +0000 (18:08 +0100)
===================================================================

Gbp-Pq: Name test_floating_point.patch

python/test/unit/geometry/test_point.py

index 2d17ad8a4f949ac67fa23d1acb472ff15c6fbd37..160a6cad6ca03826efa49a901eafb8e32aa424c0 100644 (file)
@@ -18,6 +18,7 @@
 # along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
 
 import pytest
+from pytest import approx
 import numpy as np
 
 from dolfin import *
@@ -25,19 +26,19 @@ from dolfin import *
 
 def test_point_getitem():
     p = Point(1, 2, 3)
-    assert p[0] == 1.0
-    assert p[1] == 2.0
-    assert p[2] == 3.0
+    assert p[0] == approx(1.0)
+    assert p[1] == approx(2.0)
+    assert p[2] == approx(3.0)
     with pytest.raises(IndexError):
         p[3]
-    assert np.all(p[:] == np.array((1.0, 2.0, 3.0)))
+    assert np.all(p[:] == approx(np.array((1.0, 2.0, 3.0))))
 
 
 def test_point_setitem():
     p = Point()
 
     p[0] = 6.0
-    assert p[0] == 6.0
+    assert p[0] == approx(6.0)
 
     p[1] = 16.0
     p[1] += 600.0
@@ -90,6 +91,6 @@ def test_point_dot():
     r = Point(-1.6, -2.5, 3.3)
     s = Point(152.25)
 
-    assert p.dot(q) == p[0]*q[0] + p[1]*q[1] + p[2]*q[2]
-    assert p.dot(r) == p[0]*r[0] + p[1]*r[1] + p[2]*r[2]
-    assert p.dot(s) == p[0]*s[0]
\ No newline at end of file
+    assert p.dot(q) == approx(p[0]*q[0] + p[1]*q[1] + p[2]*q[2])
+    assert p.dot(r) == approx(p[0]*r[0] + p[1]*r[1] + p[2]*r[2])
+    assert p.dot(s) == approx(p[0]*s[0])