Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make log_point more forgiving and update docstring #1663

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions rerun_py/rerun_sdk/rerun/log/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ def log_point(
timeless: bool = False,
) -> None:
"""
Log a 2D or 3D point, with a positions and optional colors, radii, label, etc.
Log a 2D or 3D point, with a position and optional color, radii, label, etc.

Logging again to the same `entity_path` will replace the previous point.

Colors should either be in 0-255 gamma space or in 0-1 linear space.
Colors can be RGB or RGBA. You can supply no colors, one color,
or one color per point in a Nx3 or Nx4 numpy array.
Colors can be RGB or RGBA represented as a 2-element or 3-element sequence.

Supported dtypes for `color`:
-----------------------------
Expand All @@ -63,7 +62,7 @@ def log_point(
entity_path:
Path to the point in the space hierarchy.
position:
2x1 or 3x1 array.
Any 2-element or 3-element array-like.
radius:
Optional radius (make it a sphere).
color:
Expand Down Expand Up @@ -96,12 +95,12 @@ def log_point(
splats: Dict[str, Any] = {}

if position is not None:
if position.shape[0] == 2:
if position.size == 2:
instanced["rerun.point2d"] = Point2DArray.from_numpy(position.reshape(1, 2))
elif position.shape[0] == 3:
elif position.size == 3:
instanced["rerun.point3d"] = Point3DArray.from_numpy(position.reshape(1, 3))
else:
raise TypeError("Positions should be either 1x2 or 1x3")
raise TypeError("Position must have a total size of 2 or 3")

if color:
colors = _normalize_colors([color])
Expand Down