Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for box dimensions and global box center (fix #5) #9

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion tests/test_e57.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import e57
import numpy as np
import pytest

import e57


def test_raw_xml():
Expand All @@ -11,3 +13,23 @@ def test_read_points():
pointcloud = e57.read_points(r"testdata/bunnyFloat.e57")
assert isinstance(pointcloud, np.ndarray)
assert len(pointcloud) == 30_571


def test_box_dimensions():
pointcloud: np.ndarray = e57.read_points(r"testdata/bunnyFloat.e57")
max_coords = pointcloud.max(0, None, False, -np.inf)
min_coords = pointcloud.min(0, None, False, np.inf)
X, Y, Z = max_coords - min_coords
assert X == pytest.approx(0.155698)
assert Y == pytest.approx(0.14731)
assert Z == pytest.approx(0.120672)


def test_global_box_center():
pointcloud: np.ndarray = e57.read_points(r"testdata/bunnyFloat.e57")
max_coords = pointcloud.max(0, None, False, -np.inf)
min_coords = pointcloud.min(0, None, False, np.inf)
X, Y, Z = (max_coords + min_coords) / 2
assert X == pytest.approx(-0.016840)
assert Y == pytest.approx(0.113666)
assert Z == pytest.approx(-0.001537)