Skip to content

Commit c2e894f

Browse files
authored
Merge pull request #9 from devdanzin/add_bunny_tests
Add tests for box dimensions and global box center (fix #5)
2 parents 69757c9 + 81395ca commit c2e894f

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

tests/test_e57.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import e57
21
import numpy as np
2+
import pytest
3+
4+
import e57
35

46

57
def test_raw_xml():
@@ -11,3 +13,23 @@ def test_read_points():
1113
pointcloud = e57.read_points(r"testdata/bunnyFloat.e57")
1214
assert isinstance(pointcloud, np.ndarray)
1315
assert len(pointcloud) == 30_571
16+
17+
18+
def test_box_dimensions():
19+
pointcloud: np.ndarray = e57.read_points(r"testdata/bunnyFloat.e57")
20+
max_coords = pointcloud.max(0, None, False, -np.inf)
21+
min_coords = pointcloud.min(0, None, False, np.inf)
22+
X, Y, Z = max_coords - min_coords
23+
assert X == pytest.approx(0.155698)
24+
assert Y == pytest.approx(0.14731)
25+
assert Z == pytest.approx(0.120672)
26+
27+
28+
def test_global_box_center():
29+
pointcloud: np.ndarray = e57.read_points(r"testdata/bunnyFloat.e57")
30+
max_coords = pointcloud.max(0, None, False, -np.inf)
31+
min_coords = pointcloud.min(0, None, False, np.inf)
32+
X, Y, Z = (max_coords + min_coords) / 2
33+
assert X == pytest.approx(-0.016840)
34+
assert Y == pytest.approx(0.113666)
35+
assert Z == pytest.approx(-0.001537)

0 commit comments

Comments
 (0)