From: Debian Science Team Date: Wed, 4 Nov 2020 23:05:55 +0000 (+0000) Subject: test_floating_point X-Git-Tag: archive/raspbian/2019.2.0_git20200629.946dbd3-8+rpi1~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2640d5be31d724ed596a1213d7a745f92f899711;p=dolfin.git test_floating_point =================================================================== Gbp-Pq: Name test_floating_point.patch --- diff --git a/python/test/unit/geometry/test_point.py b/python/test/unit/geometry/test_point.py index 2d17ad8..160a6ca 100644 --- a/python/test/unit/geometry/test_point.py +++ b/python/test/unit/geometry/test_point.py @@ -18,6 +18,7 @@ # along with DOLFIN. If not, see . 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])