diff --git a/tests/unit/network/DelaunayTest.py b/tests/unit/network/DelaunayTest.py index e6c79545b3..af1b9af153 100644 --- a/tests/unit/network/DelaunayTest.py +++ b/tests/unit/network/DelaunayTest.py @@ -1,5 +1,6 @@ import numpy as np import openpnm as op +from numpy.testing import assert_array_almost_equal class DelaunayGabrielTest: @@ -61,19 +62,21 @@ def test_delaunay_cube_with_num_points(self): def test_delaunay_disk_with_2D_points(self): np.random.seed(0) - pts = np.random.rand(50, 2) - tri = op.network.Delaunay(points=pts, shape=[1, 0]) + rqz = np.random.rand(50, 3)*np.array([1, 2*np.pi, 1]) + pts = np.vstack(op._skgraph.tools.cyl2cart(*rqz.T)).T + tri = op.network.Delaunay(points=pts[:, :2], shape=[1, 0]) assert tri.coords.shape == (50, 3) - assert np.all(tri.coords[:, :2] == pts[:, :2]) + assert_array_almost_equal(tri.coords[:, :2], pts[:, :2], decimal=15) assert np.all(tri.coords[:, -1] != pts[:, -1]) assert np.all(tri.coords[:, -1] == 0.0) def test_delaunay_disk_with_3D_points(self): np.random.seed(0) - pts = np.random.rand(50, 3) + rqz = np.random.rand(50, 3)*np.array([1, 2*np.pi, 1]) + pts = np.vstack(op._skgraph.tools.cyl2cart(*rqz.T)).T tri = op.network.Delaunay(points=pts, shape=[1, 1]) assert tri.coords.shape == (50, 3) - assert np.all(tri.coords == pts) + assert_array_almost_equal(tri.coords, pts, decimal=15) def test_delaunay_disk_with_num_points(self): np.random.seed(0) @@ -82,10 +85,11 @@ def test_delaunay_disk_with_num_points(self): def test_delaunay_cylinder_with_points(self): np.random.seed(0) - pts = np.random.rand(50, 3) + rqz = np.random.rand(50, 3)*np.array([1, 2*np.pi, 1]) + pts = np.vstack(op._skgraph.tools.cyl2cart(*rqz.T)).T tri = op.network.Delaunay(points=pts, shape=[1, 1]) assert tri.coords.shape == (50, 3) - assert np.all(tri.coords == pts) + assert_array_almost_equal(tri.coords, pts, decimal=15) def test_delaunay_sphere_with_num_points(self): np.random.seed(0)