Skip to content

Commit

Permalink
extract empty annotation creation
Browse files Browse the repository at this point in the history
  • Loading branch information
tklockau committed Oct 28, 2024
1 parent d3e6821 commit 75b7c40
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
16 changes: 16 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path

import pytest
import raillabel

json_data_directories = [
Path(__file__).parent / "__test_assets__",
Expand Down Expand Up @@ -65,3 +66,18 @@ def _load_json_data(path: Path) -> dict:
with path.open() as f:
json_data = json.load(f)
return json_data

@pytest.fixture
def empty_annotation() -> raillabel.format.Bbox:
"""Return a minimal possible annotation."""
return raillabel.format.Bbox(
uid="1f654afe-0a18-497f-9db8-afac360ce94c",
object=raillabel.format.Object(
uid="7df959d7-0ec2-4722-8b62-bb2e529de2ec",
name="person0000",
type="person",
),
sensor=None,
pos=raillabel.format.Point2d(0.0, 0.0),
size=raillabel.format.Size2d(0.0, 0.0),
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@
_is_frame_empty,
)

# == Tests ============================

def test_is_frame_empty__true():
frame = raillabel.format.Frame(uid=0, annotations={})
assert _is_frame_empty(frame)

def test_is_frame_empty__false():
def test_is_frame_empty__false(empty_annotation):
frame = raillabel.format.Frame(
uid=0, annotations={
"581b0df1-c4cf-4a97-828e-13dd740defe5": raillabel.format.Bbox(
uid=None,
object=None,
sensor=None,
attributes=None,
pos=raillabel.format.Point2d(0, 0),
size=raillabel.format.Size2d(0, 0),
)
uid=0,
annotations={
"581b0df1-c4cf-4a97-828e-13dd740defe5": empty_annotation
}
)
assert not _is_frame_empty(frame)
Expand Down

0 comments on commit 75b7c40

Please sign in to comment.