Skip to content

Commit

Permalink
test: add more anisotropic tests for hexagon
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Feb 11, 2024
1 parent 028ceb2 commit 5d11a05
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions automated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
[1,1,1],
[2,2,2],
[1000,1000,1000],
[1.2, 3.5, 0.1],
[0.0001,0.0001,0.0001],
[1, 1, 0.001],
[1, 0.001, 1],
[0.001, 1, 1],
])
def test_single_voxel(anisotropy):
voxel = np.ones([1,1,1], dtype=bool, order="F")
Expand Down Expand Up @@ -36,7 +39,6 @@ def test_single_voxel(anisotropy):
voxel, [0,0,0], [1,1,0], anisotropy,
return_contact=True
)
print(area)
assert np.isclose(area,
(
np.sqrt(anisotropy[0] * anisotropy[0] + anisotropy[1] * anisotropy[1])
Expand Down Expand Up @@ -66,11 +68,16 @@ def test_single_voxel(anisotropy):
assert contact > 0

area, contact = xs3d.cross_sectional_area(
voxel, [0,0,0], [1,1,1], #anisotropy
voxel, [0,0,0], [1,1,1], anisotropy,
return_contact=True
)
tri = np.sqrt(3) / 2 * ((0.5) ** 2)
hexagon = 6 * tri
tri = lambda s: np.sqrt(3) / 8 * (s ** 2)

if 0.001 in anisotropy:
# collapses to a 2D shape
hexagon = 0.75 # 1/4 + 1/4 + 1/8 + 1/8
else:
hexagon = 2 * sum([ tri(a) for a in anisotropy ])
assert np.isclose(area, hexagon)
assert contact > 0

Expand Down

0 comments on commit 5d11a05

Please sign in to comment.