Skip to content

Commit

Permalink
refactor: rename sensor field to sensor_id in Annotation classes
Browse files Browse the repository at this point in the history
  • Loading branch information
unexcellent committed Nov 13, 2024
1 parent ef1fac6 commit 1ba0221
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions raillabel/format/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class Bbox:
object_id: UUID
"The unique identifyer of the real-life object, this annotation belongs to."

sensor: str
"The uid of the sensor, this annotation is labeled in."
sensor_id: str
"The unique identifyer of the sensor this annotation is labeled in."

attributes: dict[str, float | bool | str | list]
"Additional information associated with the annotation."
Expand All @@ -39,7 +39,7 @@ def from_json(cls, json: JSONBbox, object_id: UUID) -> Bbox:
pos=Point2d.from_json((json.val[0], json.val[1])),
size=Size2d.from_json((json.val[2], json.val[3])),
object_id=object_id,
sensor=json.coordinate_system,
sensor_id=json.coordinate_system,
attributes=_attributes_from_json(json.attributes),
)

Expand All @@ -48,11 +48,11 @@ def to_json(self, uid: UUID, object_type: str) -> JSONBbox:
return JSONBbox(
name=self.name(object_type),
val=list(self.pos.to_json()) + list(self.size.to_json()),
coordinate_system=self.sensor,
coordinate_system=self.sensor_id,
uid=uid,
attributes=_attributes_to_json(self.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}__bbox__{object_type}"
return f"{self.sensor_id}__bbox__{object_type}"
8 changes: 4 additions & 4 deletions raillabel/format/cuboid.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Cuboid:
object_id: UUID
"The unique identifyer of the real-life object, this annotation belongs to."

sensor: str
"The uid of the sensor, this annotation is labeled in."
sensor_id: str
"The unique identifyer of the sensor this annotation is labeled in."

attributes: dict[str, float | bool | str | list]
"Additional information associated with the annotation."
Expand All @@ -45,10 +45,10 @@ def from_json(cls, json: JSONCuboid, object_id: UUID) -> Cuboid:
quat=Quaternion.from_json((json.val[3], json.val[4], json.val[5], json.val[6])),
size=Size3d.from_json((json.val[7], json.val[8], json.val[9])),
object_id=object_id,
sensor=json.coordinate_system,
sensor_id=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}__cuboid__{object_type}"
return f"{self.sensor_id}__cuboid__{object_type}"
4 changes: 2 additions & 2 deletions raillabel/format/num.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Num:
val: float
"This is the value of the number object."

sensor: str | None
sensor_id: str | None
"A reference to the sensor, this value is represented in."

@classmethod
Expand All @@ -27,5 +27,5 @@ def from_json(cls, json: JSONNum) -> Num:
return Num(
name=json.name,
val=json.val,
sensor=json.coordinate_system,
sensor_id=json.coordinate_system,
)
8 changes: 4 additions & 4 deletions raillabel/format/poly2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Poly2d:
object_id: UUID
"The unique identifyer of the real-life object, this annotation belongs to."

sensor: str
"The uid of the sensor, this annotation is labeled in."
sensor_id: str
"The unique identifyer of the sensor this annotation is labeled in."

attributes: dict[str, float | bool | str | list]
"Additional information associated with the annotation."
Expand All @@ -41,10 +41,10 @@ def from_json(cls, json: JSONPoly2d, object_id: UUID) -> Poly2d:
],
closed=json.closed,
object_id=object_id,
sensor=json.coordinate_system,
sensor_id=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}"
return f"{self.sensor_id}__poly2d__{object_type}"
8 changes: 4 additions & 4 deletions raillabel/format/poly3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Poly3d:
object_id: UUID
"The unique identifyer of the real-life object, this annotation belongs to."

sensor: str
"The uid of the sensor, this annotation is labeled in."
sensor_id: str
"The unique identifyer of the sensor this annotation is labeled in."

attributes: dict[str, float | bool | str | list]
"Additional information associated with the annotation."
Expand All @@ -41,10 +41,10 @@ def from_json(cls, json: JSONPoly3d, object_id: UUID) -> Poly3d:
],
closed=json.closed,
object_id=object_id,
sensor=json.coordinate_system,
sensor_id=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}__poly3d__{object_type}"
return f"{self.sensor_id}__poly3d__{object_type}"
8 changes: 4 additions & 4 deletions raillabel/format/seg3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Seg3d:
object_id: UUID
"The unique identifyer of the real-life object, this annotation belongs to."

sensor: str
"The uid of the sensor, this annotation is labeled in."
sensor_id: str
"The unique identifyer of the sensor this annotation is labeled in."

attributes: dict[str, float | bool | str | list]
"Additional information associated with the annotation."
Expand All @@ -33,10 +33,10 @@ def from_json(cls, json: JSONVec, object_id: UUID) -> Seg3d:
return Seg3d(
point_ids=[int(point_id) for point_id in json.val],
object_id=object_id,
sensor=json.coordinate_system,
sensor_id=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}__vec__{object_type}"
return f"{self.sensor_id}__vec__{object_type}"
2 changes: 1 addition & 1 deletion tests/test_raillabel/format/test_bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def bbox(
return Bbox(
pos=point2d,
size=size2d,
sensor="rgb_middle",
sensor_id="rgb_middle",
attributes=attributes_multiple_types,
object_id=object_person_id,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_raillabel/format/test_cuboid.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def cuboid(
pos=point3d,
quat=quaternion,
size=size3d,
sensor="lidar",
sensor_id="lidar",
attributes=attributes_multiple_types,
object_id=object_person_id,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_raillabel/format/test_num.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def num_json() -> JSONNum:
@pytest.fixture
def num() -> Num:
return Num(
sensor="gps_imu",
sensor_id="gps_imu",
name="velocity",
val=49.21321,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_raillabel/format/test_poly2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def poly2d(
return Poly2d(
points=[point2d, another_point2d],
closed=True,
sensor="rgb_middle",
sensor_id="rgb_middle",
attributes=attributes_multiple_types,
object_id=object_track_id,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_raillabel/format/test_poly3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def poly3d(
return Poly3d(
points=[point3d, another_point3d],
closed=True,
sensor="lidar",
sensor_id="lidar",
attributes=attributes_multiple_types,
object_id=object_track_id,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_raillabel/format/test_seg3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def seg3d(
) -> Seg3d:
return Seg3d(
point_ids=[1234, 5678],
sensor="lidar",
sensor_id="lidar",
attributes=attributes_multiple_types,
object_id=object_person_id,
)
Expand Down

0 comments on commit 1ba0221

Please sign in to comment.