Skip to content

Commit 1cac72f

Browse files
fixed nits
1 parent 7ca9e8b commit 1cac72f

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

t4_devkit/dataclass/pointcloud.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"SegmentationPointCloud",
2222
"PointCloudLike",
2323
"PointCloudMetainfo",
24-
"PointcloudSourceInfo",
24+
"PointCloudSourceInfo",
2525
"Stamp",
2626
]
2727

@@ -38,9 +38,17 @@ class Stamp:
3838
sec: int
3939
nanosec: int
4040

41+
@property
42+
def in_seconds(self) -> float:
43+
"""Convert timestamp to seconds as a float.
4144
45+
Returns:
46+
float: Timestamp in seconds.
47+
"""
48+
return self.sec + self.nanosec * 1e-9
49+
4250
@define
43-
class PointcloudSourceInfo:
51+
class PointCloudSourceInfo:
4452
"""A dataclass to represent pointcloud source information.
4553
4654
Attributes:
@@ -62,11 +70,11 @@ class PointCloudMetainfo:
6270
6371
Attributes:
6472
stamp (Stamp): Timestamp.
65-
sources (list[PointcloudSourceInfo]): List of source information.
73+
sources (list[PointCloudSourceInfo]): List of source information.
6674
"""
6775

6876
stamp: Stamp = field(converter=lambda x: Stamp(**x) if isinstance(x, dict) else x)
69-
sources: list[PointcloudSourceInfo] = field(factory=list)
77+
sources: list[PointCloudSourceInfo] = field(factory=list)
7078

7179
@classmethod
7280
def from_file(cls, filepath: str) -> Self:
@@ -82,7 +90,7 @@ def from_file(cls, filepath: str) -> Self:
8290
stamp = Stamp(**data["stamp"])
8391
sources = []
8492
for source_data in data.get("sources", []):
85-
sources.append(PointcloudSourceInfo(**source_data))
93+
sources.append(PointCloudSourceInfo(**source_data))
8694
return cls(stamp=stamp, sources=sources)
8795

8896
@property
@@ -94,7 +102,6 @@ def source_tokens(self) -> list[str]:
94102
"""
95103
return [source.sensor_token for source in self.sources]
96104

97-
98105
@define
99106
class PointCloud:
100107
"""Abstract base dataclass for pointcloud data."""

t4_devkit/sanity/reference/ref301.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ class REF301(ExternalReferenceChecker):
2929
reference = "token"
3030

3131
def check(self, context: SanityContext) -> list[Reason] | None:
32+
"""Check that all sensor tokens in PointCloudMetainfo files exist in Sensor schema.
33+
34+
Validates that all source tokens found in pointcloud info files reference valid
35+
sensor tokens from the sensor schema.
36+
37+
Args:
38+
context: The sanity check context containing schema files and data root.
39+
40+
Returns:
41+
List of Reason objects for invalid sensor token references, or None if all valid.
42+
"""
3243
sensor_token_filepath = context.to_schema_file(self.target).unwrap()
3344
sensor_tokens = {
3445
item[self.reference] for item in load_json_safe(sensor_token_filepath).unwrap()
@@ -41,7 +52,7 @@ def check(self, context: SanityContext) -> list[Reason] | None:
4152
# Get all valid pointcloud info records with their filenames
4253
valid_records = (
4354
(
44-
record.get("info_filename", ""),
55+
record.get("info_filename"),
4556
PointCloudMetainfo.from_file(
4657
data_root.joinpath(record.get("info_filename"))
4758
).source_tokens,

0 commit comments

Comments
 (0)