Skip to content

Commit

Permalink
tweaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Jun 6, 2023
1 parent 27f53a4 commit 69e6708
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/unit/network/DelaunayTest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import openpnm as op
from numpy.testing import assert_array_almost_equal


class DelaunayGabrielTest:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 69e6708

Please sign in to comment.