From e1474ae4d4f2f7b6da20af4b49fe906b7e610b71 Mon Sep 17 00:00:00 2001 From: ktro2828 Date: Wed, 11 Feb 2026 07:41:17 +0900 Subject: [PATCH 1/5] style: add docstrings Signed-off-by: ktro2828 --- t4_devkit/helper/rendering.py | 4 ++++ t4_devkit/viewer/builder.py | 39 +++++++++++++++++++++++++++++++++++ t4_devkit/viewer/color.py | 3 +++ t4_devkit/viewer/config.py | 9 ++++++++ 4 files changed, 55 insertions(+) diff --git a/t4_devkit/helper/rendering.py b/t4_devkit/helper/rendering.py index 1c748078..938269a4 100644 --- a/t4_devkit/helper/rendering.py +++ b/t4_devkit/helper/rendering.py @@ -41,6 +41,8 @@ class RenderingMode(Enum): + """Rendering mode enumerations.""" + SCENE = "scene" INSTANCE = "instance" POINTCLOUD = "pointcloud" @@ -66,9 +68,11 @@ def __init__(self, t4: Tier4) -> None: self._executor = concurrent.futures.ThreadPoolExecutor() def _has_lidarseg(self) -> bool: + """Return `True` if the dataset includes lidarseg.""" return bool(self._sample_data_to_lidarseg_filename) def _find_lidarseg_file(self, sample_data_token: str) -> str | None: + """Try to find lidarseg filename from the sample data token.""" return self._sample_data_to_lidarseg_filename.get(sample_data_token) def _init_viewer( diff --git a/t4_devkit/viewer/builder.py b/t4_devkit/viewer/builder.py index bb27eec8..77c6b4fc 100644 --- a/t4_devkit/viewer/builder.py +++ b/t4_devkit/viewer/builder.py @@ -33,10 +33,24 @@ def __init__(self) -> None: self._config = ViewerConfig() def with_spatial3d(self) -> Self: + """Update the viewer configurtion to include 3D view space. + + Returns: + Self: Updated `ViewerBuilder` instance itself. + """ self._config.spatial3ds.append(rrb.Spatial3DView(name="3D", origin=EntityPath.MAP)) return self def with_spatial2d(self, cameras: Sequence[str], contents: list[str] | None = None) -> Self: + """Update the viewer configuration to include 2D view spaces for each camera. + + Args: + cameras (Sequenece[str]): Camera names. + contents (list[str] | None): List of 3D view contents to project onto 2D view spaces. + + Returns: + Self: Updated `ViewerBuilder` instance itself. + """ # Preserve the original contents arguments so each camera gets its own view_contents. base_contents = contents for name in cameras: @@ -53,14 +67,39 @@ def with_spatial2d(self, cameras: Sequence[str], contents: list[str] | None = No return self def with_labels(self, label2id: dict[str, int]) -> Self: + """Update the viewer configuration to include label to id mapping. + + Args: + label2id (dict[str, int]): Key-value mapping to convert label name to its ID. + + Returns: + Self: Updated `ViewerBuilder` instance itself. + """ self._config.label2id = label2id return self def with_streetmap(self, latlon: Vector2Like | None = None) -> Self: + """Update the viewer configuration to include the streetmap view space. + + Args: + latlon (Vector2Like | None): Starting point in (latitude, longitude). + + Returns: + Self: Updated `ViewerBuilder` instance itself. + """ self._config.spatial3ds.append(rrb.MapView(name="Map", origin=EntityPath.GEOCOORDINATE)) if latlon is not None: self._config.latlon = latlon return self def build(self, app_id: str, save_dir: str | None = None) -> RerunViewer: + """Build `RerunViewer` from the configuration. + + Args: + app_id (str): Viewer application ID. + save_dir (str | None): Directory path to save the rendering record. + + Returns: + RerunViewer: Viewer instance. + """ return RerunViewer(app_id=app_id, config=self._config, save_dir=save_dir) diff --git a/t4_devkit/viewer/color.py b/t4_devkit/viewer/color.py index 435abc38..fb465f8f 100644 --- a/t4_devkit/viewer/color.py +++ b/t4_devkit/viewer/color.py @@ -32,6 +32,9 @@ def pointcloud_color( Args: pointcloud (PointCloudLike): Any inheritance of `PointCloud` class. color_mode (PointCloudColorMode, optional): Color mode for pointcloud. + + Returns: + NDArrayF64: RGB color array in the shape of (N, 3). """ match color_mode: case PointCloudColorMode.DISTANCE: diff --git a/t4_devkit/viewer/config.py b/t4_devkit/viewer/config.py index 5c15d344..9a848079 100644 --- a/t4_devkit/viewer/config.py +++ b/t4_devkit/viewer/config.py @@ -30,6 +30,15 @@ class EntityPath(str, Enum): @define class ViewerConfig: + """Viewer configuration. + + Attributes: + spatial3ds (list[rrb.Spatial3DView] | rrb.MapView): List of 3D spatial views. + spatial2ds (list[rrb.Spatial2Dview]): List of 2D spatial views. + label2id (dict[str, int]): Key-value mapping to convert label name to its ID. + latlon (Vector2Like | None): Starting point in (latitude, longitude). + """ + spatial3ds: list[rrb.Spatial3DView | rrb.MapView] = field(factory=list) spatial2ds: list[rrb.Spatial2DView] = field(factory=list) label2id: dict[str, int] = field(factory=dict) From b658a398e6110a02fc28aa3887403fb07eb6c4a4 Mon Sep 17 00:00:00 2001 From: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:43:15 +0900 Subject: [PATCH 2/5] Update t4_devkit/viewer/config.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- t4_devkit/viewer/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t4_devkit/viewer/config.py b/t4_devkit/viewer/config.py index 9a848079..7c2672e4 100644 --- a/t4_devkit/viewer/config.py +++ b/t4_devkit/viewer/config.py @@ -33,7 +33,7 @@ class ViewerConfig: """Viewer configuration. Attributes: - spatial3ds (list[rrb.Spatial3DView] | rrb.MapView): List of 3D spatial views. + spatial3ds (list[rrb.Spatial3DView | rrb.MapView]): List of 3D spatial views. spatial2ds (list[rrb.Spatial2Dview]): List of 2D spatial views. label2id (dict[str, int]): Key-value mapping to convert label name to its ID. latlon (Vector2Like | None): Starting point in (latitude, longitude). From bdeae78084e68396f8e729779035fe8078198358 Mon Sep 17 00:00:00 2001 From: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:43:29 +0900 Subject: [PATCH 3/5] Update t4_devkit/viewer/builder.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- t4_devkit/viewer/builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t4_devkit/viewer/builder.py b/t4_devkit/viewer/builder.py index 77c6b4fc..5ad6eb8f 100644 --- a/t4_devkit/viewer/builder.py +++ b/t4_devkit/viewer/builder.py @@ -45,7 +45,7 @@ def with_spatial2d(self, cameras: Sequence[str], contents: list[str] | None = No """Update the viewer configuration to include 2D view spaces for each camera. Args: - cameras (Sequenece[str]): Camera names. + cameras (Sequence[str]): Camera names. contents (list[str] | None): List of 3D view contents to project onto 2D view spaces. Returns: From 44c4527b72d774abe009a99faf30a127c556f34e Mon Sep 17 00:00:00 2001 From: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:43:37 +0900 Subject: [PATCH 4/5] Update t4_devkit/viewer/builder.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- t4_devkit/viewer/builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t4_devkit/viewer/builder.py b/t4_devkit/viewer/builder.py index 5ad6eb8f..e33b6ddd 100644 --- a/t4_devkit/viewer/builder.py +++ b/t4_devkit/viewer/builder.py @@ -33,7 +33,7 @@ def __init__(self) -> None: self._config = ViewerConfig() def with_spatial3d(self) -> Self: - """Update the viewer configurtion to include 3D view space. + """Update the viewer configuration to include 3D view space. Returns: Self: Updated `ViewerBuilder` instance itself. From af4dd9dd36d62e287180a7d62f6dfb980e50de56 Mon Sep 17 00:00:00 2001 From: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com> Date: Wed, 11 Feb 2026 07:43:53 +0900 Subject: [PATCH 5/5] Update t4_devkit/viewer/config.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- t4_devkit/viewer/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t4_devkit/viewer/config.py b/t4_devkit/viewer/config.py index 7c2672e4..1c894b20 100644 --- a/t4_devkit/viewer/config.py +++ b/t4_devkit/viewer/config.py @@ -34,7 +34,7 @@ class ViewerConfig: Attributes: spatial3ds (list[rrb.Spatial3DView | rrb.MapView]): List of 3D spatial views. - spatial2ds (list[rrb.Spatial2Dview]): List of 2D spatial views. + spatial2ds (list[rrb.Spatial2DView]): List of 2D spatial views. label2id (dict[str, int]): Key-value mapping to convert label name to its ID. latlon (Vector2Like | None): Starting point in (latitude, longitude). """