Skip to content

Commit 86d79aa

Browse files
committed
Py: Refactor tests
1 parent 481691a commit 86d79aa

File tree

3 files changed

+45
-36
lines changed

3 files changed

+45
-36
lines changed

pysplashsurf/tests/test_basic.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import pysplashsurf
2+
import numpy as np
3+
import meshio
4+
5+
6+
def test_aabb_class():
7+
print("\nTesting AABB class")
8+
9+
aabb = pysplashsurf.Aabb3d.from_min_max(min=[0.0, 0.0, 0.0], max=[1.0, 2.0, 3.0])
10+
assert (aabb.min == np.array([0.0, 0.0, 0.0])).all()
11+
assert (aabb.max == np.array([1.0, 2.0, 3.0])).all()
12+
13+
aabb = pysplashsurf.Aabb3d.from_min_max(
14+
min=np.array([0.0, 0.0, 0.0]), max=np.array([1.0, 2.0, 3.0])
15+
)
16+
assert (aabb.min == np.array([0.0, 0.0, 0.0])).all()
17+
assert (aabb.max == np.array([1.0, 2.0, 3.0])).all()
18+
19+
aabb = pysplashsurf.Aabb3d.from_points(
20+
np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [2.0, 0.5, 4.2]])
21+
)
22+
23+
print("AABB min:", aabb.min)
24+
print("AABB max:", aabb.max)
25+
26+
assert (aabb.min == np.array([0.0, 0.0, 0.0])).all()
27+
assert (aabb.max == np.array([2.0, 1.0, 4.2])).all()
28+
29+
assert aabb.contains_point([1.0, 0.9, 4.1])
30+
assert aabb.contains_point([0.0, 0.0, 0.0])
31+
assert not aabb.contains_point([2.0, 1.0, 4.2])
32+
assert not aabb.contains_point([1.0, -1.0, 5.0])

pysplashsurf/tests/test_bgeo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import pysplashsurf
2+
import numpy as np
3+
import meshio
4+
import pathlib
5+
6+
DIR = pathlib.Path(__file__).parent.resolve()
7+
BGEO_PATH = DIR.joinpath("ParticleData_Fluid_50.bgeo")
8+
9+
10+
def test_bgeo():
11+
particles = np.array(meshio.read(BGEO_PATH).points, dtype=np.float32)
12+
13+
assert len(particles) == 4732

pysplashsurf/tests/test_calling.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pysplashsurf
22
import numpy as np
3-
import math
43
import meshio
54
import subprocess
65
import time
@@ -9,47 +8,13 @@
98

109
BINARY_PATH = "splashsurf"
1110
DIR = pathlib.Path(__file__).parent.resolve()
12-
BGEO_PATH = DIR.joinpath("ParticleData_Fluid_50.bgeo")
1311
VTK_PATH = DIR.joinpath("ParticleData_Fluid_5.vtk")
1412

1513

1614
def now_s():
1715
return time.process_time_ns() / (10**9)
1816

1917

20-
def test_bgeo():
21-
particles = np.array(meshio.read(BGEO_PATH).points, dtype=np.float32)
22-
23-
assert len(particles) == 4732
24-
25-
26-
def test_aabb_class():
27-
print("\nTesting AABB class")
28-
29-
aabb = pysplashsurf.Aabb3d.from_min_max(min=[0.0, 0.0, 0.0], max=[1.0, 2.0, 3.0])
30-
assert (aabb.min == np.array([0.0, 0.0, 0.0])).all()
31-
assert (aabb.max == np.array([1.0, 2.0, 3.0])).all()
32-
33-
aabb = pysplashsurf.Aabb3d.from_min_max(min=np.array([0.0, 0.0, 0.0]), max=np.array([1.0, 2.0, 3.0]))
34-
assert (aabb.min == np.array([0.0, 0.0, 0.0])).all()
35-
assert (aabb.max == np.array([1.0, 2.0, 3.0])).all()
36-
37-
aabb = pysplashsurf.Aabb3d.from_points(
38-
np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [2.0, 0.5, 4.2]])
39-
)
40-
41-
print("AABB min:", aabb.min)
42-
print("AABB max:", aabb.max)
43-
44-
assert (aabb.min == np.array([0.0, 0.0, 0.0])).all()
45-
assert (aabb.max == np.array([2.0, 1.0, 4.2])).all()
46-
47-
assert aabb.contains_point([1.0, 0.9, 4.1])
48-
assert aabb.contains_point([0.0, 0.0, 0.0])
49-
assert not aabb.contains_point([2.0, 1.0, 4.2])
50-
assert not aabb.contains_point([1.0, -1.0, 5.0])
51-
52-
5318
def test_marching_cubes_calls():
5419
print("\nTesting marching cubes calls")
5520

@@ -284,4 +249,3 @@ def test_with_post_processing():
284249
print("Python verts:", python_verts)
285250

286251
assert np.allclose(binary_verts, python_verts)
287-

0 commit comments

Comments
 (0)