Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion perceptionmetrics/utils/detection_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def get_overall_precision_recall_curve(self) -> Dict[str, List[float]]:
return {"precision": [0.0], "recall": [0.0]}

fn_count = sum(1 for d in all_detections if d[1] == -1)

# Sort by score
all_detections = sorted(
[d for d in all_detections if d[0] is not None], key=lambda x: -x[0]
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# tests/conftest.py
# Pre-import open3d before any test module is collected.
# test_yolo.py stubs open3d only if it's NOT already in sys.modules.
# Loading it here first ensures test_lidar.py gets the real open3d.
import open3d # noqa: F401
4 changes: 2 additions & 2 deletions tests/test_lidar.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_build_point_cloud(self, sample_points, sample_colors):
"""Test build_point_cloud creates proper Open3D point cloud."""
point_cloud = build_point_cloud(sample_points, sample_colors)

assert isinstance(point_cloud, o3d.geometry.PointCloud)
assert type(point_cloud).__name__ == "PointCloud"
assert len(point_cloud.points) == len(sample_points)
assert len(point_cloud.colors) == len(sample_colors)
assert np.allclose(np.asarray(point_cloud.points), sample_points)
Expand All @@ -220,7 +220,7 @@ def test_view_point_cloud(self, mock_draw, sample_points, sample_colors):
mock_draw.assert_called_once()
args = mock_draw.call_args[0][0]
assert len(args) == 1
assert isinstance(args[0], o3d.geometry.PointCloud)
assert type(args[0]).__name__ == "PointCloud"

@patch("open3d.visualization.rendering.OffscreenRenderer")
def test_render_point_cloud(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

import pandas as pd

# ---------------------------------------------------------------------------
# Try importing real optional C-extensions first so they get cached in
# sys.modules. This prevents the stub block below from replacing a real
# library that IS available in the environment (e.g. open3d), which would
# otherwise leak a MagicMock into other test modules like test_lidar.py.
# ---------------------------------------------------------------------------
for _real in ("open3d", "supervision"):
try:
__import__(_real)
except ImportError:
pass

# ---------------------------------------------------------------------------
# Stub out heavy optional C-extensions that are not available in the test
# environment (open3d, tqdm, etc.) before importing any perceptionmetrics module.
Expand Down