| 1 |
Index: dolfin/python/test/unit/geometry/test_point.py |
| 2 |
=================================================================== |
| 3 |
--- dolfin.orig/python/test/unit/geometry/test_point.py 2020-08-10 14:49:46.822387811 +0800 |
| 4 |
+++ dolfin/python/test/unit/geometry/test_point.py 2020-08-10 14:50:49.010791626 +0800 |
| 5 |
@@ -18,6 +18,7 @@ |
| 6 |
# along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 7 |
|
| 8 |
import pytest |
| 9 |
+from pytest import approx |
| 10 |
import numpy as np |
| 11 |
|
| 12 |
from dolfin import * |
| 13 |
@@ -25,19 +26,19 @@ |
| 14 |
|
| 15 |
def test_point_getitem(): |
| 16 |
p = Point(1, 2, 3) |
| 17 |
- assert p[0] == 1.0 |
| 18 |
- assert p[1] == 2.0 |
| 19 |
- assert p[2] == 3.0 |
| 20 |
+ assert p[0] == approx(1.0) |
| 21 |
+ assert p[1] == approx(2.0) |
| 22 |
+ assert p[2] == approx(3.0) |
| 23 |
with pytest.raises(IndexError): |
| 24 |
p[3] |
| 25 |
- assert np.all(p[:] == np.array((1.0, 2.0, 3.0))) |
| 26 |
+ assert np.all(p[:] == approx(np.array((1.0, 2.0, 3.0)))) |
| 27 |
|
| 28 |
|
| 29 |
def test_point_setitem(): |
| 30 |
p = Point() |
| 31 |
|
| 32 |
p[0] = 6.0 |
| 33 |
- assert p[0] == 6.0 |
| 34 |
+ assert p[0] == approx(6.0) |
| 35 |
|
| 36 |
p[1] = 16.0 |
| 37 |
p[1] += 600.0 |
| 38 |
@@ -90,6 +91,6 @@ |
| 39 |
r = Point(-1.6, -2.5, 3.3) |
| 40 |
s = Point(152.25) |
| 41 |
|
| 42 |
- assert p.dot(q) == p[0]*q[0] + p[1]*q[1] + p[2]*q[2] |
| 43 |
- assert p.dot(r) == p[0]*r[0] + p[1]*r[1] + p[2]*r[2] |
| 44 |
- assert p.dot(s) == p[0]*s[0] |
| 45 |
\ No newline at end of file |
| 46 |
+ assert p.dot(q) == approx(p[0]*q[0] + p[1]*q[1] + p[2]*q[2]) |
| 47 |
+ assert p.dot(r) == approx(p[0]*r[0] + p[1]*r[1] + p[2]*r[2]) |
| 48 |
+ assert p.dot(s) == approx(p[0]*s[0]) |