Skip to content

Commit d9964ab

Browse files
authored
docs(sdk): add documentation to Object3D for individual methods (wandb#4810)
docs(sdk): add documentation to Object3D for individual methods
1 parent edbf980 commit d9964ab

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

wandb/sdk/data_types/object_3d.py

+39-4
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,12 @@ def __init__(
198198

199199
if len(np_data.shape) != 2 or np_data.shape[1] not in {3, 4, 6}:
200200
raise ValueError(
201-
"""The shape of the numpy array must be one of either
201+
"""
202+
The shape of the numpy array must be one of either
202203
[[x y z], ...] nx3
203204
[x y z c], ...] nx4 where c is a category with supported range [1, 14]
204-
[x y z r g b], ...] nx4 where is rgb is color"""
205+
[x y z r g b], ...] nx6 where rgb is color
206+
"""
205207
)
206208

207209
list_data = np_data.tolist()
@@ -224,6 +226,13 @@ def from_file(
224226
data_or_path: Union["TextIO", str],
225227
file_type: Optional["FileFormat3D"] = None,
226228
) -> "Object3D":
229+
"""Initializes Object3D from a file or stream.
230+
231+
Arguments:
232+
data_or_path (Union["TextIO", str]): A path to a file or a `TextIO` stream.
233+
file_type (str): Specifies the data format passed to `data_or_path`. Required when `data_or_path` is a
234+
`TextIO` stream. This parameter is ignored if a file path is provided. The type is taken from the file extension.
235+
"""
227236
# if file_type is not None and file_type not in cls.SUPPORTED_TYPES:
228237
# raise ValueError(
229238
# f"Unsupported file type: {file_type}. Supported types are: {cls.SUPPORTED_TYPES}"
@@ -232,15 +241,31 @@ def from_file(
232241

233242
@classmethod
234243
def from_numpy(cls, data: "np.ndarray") -> "Object3D":
244+
"""Initializes Object3D from a numpy array.
245+
246+
Arguments:
247+
data (numpy array): Each entry in the array will
248+
represent one point in the point cloud.
249+
250+
251+
The shape of the numpy array must be one of either:
252+
```
253+
[[x y z], ...] # nx3.
254+
[[x y z c], ...] # nx4 where c is a category with supported range [1, 14].
255+
[[x y z r g b], ...] # nx6 where is rgb is color.
256+
```
257+
"""
235258
if not util.is_numpy_array(data):
236259
raise ValueError("`data` must be a numpy array")
237260

238261
if len(data.shape) != 2 or data.shape[1] not in {3, 4, 6}:
239262
raise ValueError(
240-
"""The shape of the numpy array must be one of either
263+
"""
264+
The shape of the numpy array must be one of either:
241265
[[x y z], ...] nx3
242266
[x y z c], ...] nx4 where c is a category with supported range [1, 14]
243-
[x y z r g b], ...] nx4 where is rgb is color"""
267+
[x y z r g b], ...] nx6 where rgb is color
268+
"""
244269
)
245270

246271
return cls(data)
@@ -254,6 +279,16 @@ def from_point_cloud(
254279
point_cloud_type: "PointCloudType" = "lidar/beta",
255280
# camera: Optional[Camera] = None,
256281
) -> "Object3D":
282+
"""Initializes Object3D from a python object.
283+
284+
Arguments:
285+
points (Sequence["Point"]): The points in the point cloud.
286+
boxes (Sequence["Box3D"]): 3D bounding boxes for labeling the point cloud. Boxes
287+
are displayed in point cloud visualizations.
288+
vectors (Optional[Sequence["Vector3D"]]): Each vector is displayed in the point cloud
289+
visualization. Can be used to indicate directionality of bounding boxes. Defaults to None.
290+
point_cloud_type ("lidar/beta"): At this time, only the "lidar/beta" type is supported. Defaults to "lidar/beta".
291+
"""
257292
if point_cloud_type not in cls.SUPPORTED_POINT_CLOUD_TYPES:
258293
raise ValueError("Point cloud type not supported")
259294

0 commit comments

Comments
 (0)