Skip to content

Commit

Permalink
feat: implement Poly2d.name()
Browse files Browse the repository at this point in the history
  • Loading branch information
tklockau committed Nov 11, 2024
1 parent a2d6e24 commit 94d4565
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions raillabel/format/poly2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ def from_json(cls, json: JSONPoly2d, object_uid: UUID) -> Poly2d:
sensor=json.coordinate_system,
attributes=_attributes_from_json(json.attributes),
)

def name(self, object_type: str) -> str:
"""Return the name of the annotation used for indexing in the object data pointers."""
return f"{self.sensor}__poly2d__{object_type}"
10 changes: 5 additions & 5 deletions tests/test_raillabel/format/test_poly2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def poly2d_json(
closed=True,
mode="MODE_POLY2D_ABSOLUTE",
val=point2d_json + another_point2d_json,
coordinate_system="lidar",
coordinate_system="rgb_middle",
attributes=attributes_multiple_types_json,
)

Expand All @@ -39,7 +39,7 @@ def poly2d(
return Poly2d(
points=[point2d, another_point2d],
closed=True,
sensor="lidar",
sensor="rgb_middle",
attributes=attributes_multiple_types,
object=UUID("b40ba3ad-0327-46ff-9c28-2506cfd6d934"),
)
Expand All @@ -53,9 +53,9 @@ def test_from_json(poly2d, poly2d_json):
assert actual == poly2d


# def test_name(poly2d):
# actual = poly2d.name("person")
# assert actual == "lidar__poly2d__person"
def test_name(poly2d):
actual = poly2d.name("person")
assert actual == "rgb_middle__poly2d__person"


if __name__ == "__main__":
Expand Down

0 comments on commit 94d4565

Please sign in to comment.