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

Python SDK: document that we also accept colors in 0-1 floats #1740

Merged
merged 7 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rerun_py/rerun_sdk/rerun/log/arrow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Sequence
from typing import Any, Dict, Optional

import numpy as np
import numpy.typing as npt
Expand All @@ -9,7 +9,7 @@
from rerun.components.instance import InstanceArray
from rerun.components.label import LabelArray
from rerun.components.radius import RadiusArray
from rerun.log import _normalize_colors, _normalize_radii
from rerun.log import Color, _normalize_colors, _normalize_radii
from rerun.log.extension_components import _add_extension_components
from rerun.log.log_decorator import log_decorator

Expand All @@ -24,7 +24,7 @@ def log_arrow(
origin: Optional[npt.ArrayLike],
vector: Optional[npt.ArrayLike] = None,
*,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
label: Optional[str] = None,
width_scale: Optional[float] = None,
ext: Optional[Dict[str, Any]] = None,
Expand All @@ -48,7 +48,7 @@ def log_arrow(
vector
The vector along which the arrow will be drawn.
color
An optional RGB or RGBA triplet in 0-255 sRGB.
An Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
label
An optional text to show beside the arrow.
width_scale
Expand Down
8 changes: 4 additions & 4 deletions rerun_py/rerun_sdk/rerun/log/bounding_box.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Sequence
from typing import Any, Dict, Optional

import numpy as np
import numpy.typing as npt
Expand All @@ -12,7 +12,7 @@
from rerun.components.quaternion import QuaternionArray
from rerun.components.radius import RadiusArray
from rerun.components.vec import Vec3DArray
from rerun.log import _normalize_colors, _normalize_ids, _normalize_radii
from rerun.log import Color, _normalize_colors, _normalize_ids, _normalize_radii
from rerun.log.extension_components import _add_extension_components
from rerun.log.log_decorator import log_decorator

Expand All @@ -27,7 +27,7 @@ def log_obb(
half_size: Optional[npt.ArrayLike],
position: Optional[npt.ArrayLike] = None,
rotation_q: Optional[npt.ArrayLike] = None,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
stroke_width: Optional[float] = None,
label: Optional[str] = None,
class_id: Optional[int] = None,
Expand All @@ -54,7 +54,7 @@ def log_obb(
rotation_q:
Optional array with quaternion coordinates [x, y, z, w] for the rotation from model to world space.
color:
Optional RGB or RGBA triplet in 0-255 sRGB.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
stroke_width:
Optional width of the line edges.
label:
Expand Down
14 changes: 7 additions & 7 deletions rerun_py/rerun_sdk/rerun/log/lines.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Sequence
from typing import Any, Dict, Optional

import numpy as np
import numpy.typing as npt
Expand All @@ -9,7 +9,7 @@
from rerun.components.instance import InstanceArray
from rerun.components.linestrip import LineStrip2DArray, LineStrip3DArray
from rerun.components.radius import RadiusArray
from rerun.log import _normalize_colors, _normalize_radii
from rerun.log import Color, _normalize_colors, _normalize_radii
from rerun.log.extension_components import _add_extension_components
from rerun.log.log_decorator import log_decorator

Expand All @@ -26,7 +26,7 @@ def log_path(
positions: Optional[npt.ArrayLike],
*,
stroke_width: Optional[float] = None,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
ext: Optional[Dict[str, Any]] = None,
timeless: bool = False,
) -> None:
Expand All @@ -39,7 +39,7 @@ def log_line_strip(
positions: Optional[npt.ArrayLike],
*,
stroke_width: Optional[float] = None,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
ext: Optional[Dict[str, Any]] = None,
timeless: bool = False,
) -> None:
Expand All @@ -65,7 +65,7 @@ def log_line_strip(
stroke_width:
Optional width of the line.
color:
Optional RGB or RGBA triplet in 0-255 sRGB.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
ext:
Optional dictionary of extension components. See [rerun.log_extension_components][]
timeless:
Expand Down Expand Up @@ -114,7 +114,7 @@ def log_line_segments(
positions: npt.ArrayLike,
*,
stroke_width: Optional[float] = None,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
ext: Optional[Dict[str, Any]] = None,
timeless: bool = False,
) -> None:
Expand All @@ -139,7 +139,7 @@ def log_line_segments(
stroke_width:
Optional width of the line.
color:
Optional RGB or RGBA triplet in 0-255 sRGB.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
ext:
Optional dictionary of extension components. See [rerun.log_extension_components][]
timeless:
Expand Down
4 changes: 2 additions & 2 deletions rerun_py/rerun_sdk/rerun/log/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def log_point(
position: Optional[npt.ArrayLike] = None,
*,
radius: Optional[float] = None,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
label: Optional[str] = None,
class_id: Optional[int] = None,
keypoint_id: Optional[int] = None,
Expand Down Expand Up @@ -66,7 +66,7 @@ def log_point(
radius:
Optional radius (make it a sphere).
color:
Optional color of the point.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
label:
Optional text to show with the point.
class_id:
Expand Down
4 changes: 2 additions & 2 deletions rerun_py/rerun_sdk/rerun/log/rects.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def log_rect(
rect: Optional[npt.ArrayLike],
*,
rect_format: RectFormat = RectFormat.XYWH,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
label: Optional[str] = None,
class_id: Optional[int] = None,
ext: Optional[Dict[str, Any]] = None,
Expand All @@ -52,7 +52,7 @@ def log_rect(
rect_format:
how to interpret the `rect` argument
color:
Optional RGB or RGBA triplet in 0-255 sRGB.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
label:
Optional text to show inside the rectangle.
class_id:
Expand Down
10 changes: 5 additions & 5 deletions rerun_py/rerun_sdk/rerun/log/scalar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Sequence
from typing import Any, Dict, Optional

import numpy as np

Expand All @@ -8,7 +8,7 @@
from rerun.components.label import LabelArray
from rerun.components.radius import RadiusArray
from rerun.components.scalar import ScalarArray, ScalarPlotPropsArray
from rerun.log import _normalize_colors
from rerun.log import Color, _normalize_colors
from rerun.log.extension_components import _add_extension_components
from rerun.log.log_decorator import log_decorator

Expand All @@ -22,7 +22,7 @@ def log_scalar(
entity_path: str,
scalar: float,
label: Optional[str] = None,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
radius: Optional[float] = None,
scattered: Optional[bool] = None,
ext: Optional[Dict[str, Any]] = None,
Expand Down Expand Up @@ -81,7 +81,7 @@ def log_scalar(
line will be named after the entity path. The plot itself is named after
the space it's in.
color:
An optional color in the form of a RGB or RGBA triplet in 0-255 sRGB.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.

If left unspecified, a pseudo-random color will be used instead. That
same color will apply to all points residing in the same entity path
Expand Down Expand Up @@ -121,7 +121,7 @@ def log_scalar(
instanced["rerun.label"] = LabelArray.new([label])

if color:
colors = _normalize_colors(np.array([color]))
colors = _normalize_colors([color])
instanced["rerun.colorrgba"] = ColorRGBAArray.from_numpy(colors)

if radius:
Expand Down
8 changes: 4 additions & 4 deletions rerun_py/rerun_sdk/rerun/log/text.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
from typing import Any, Dict, Final, Optional, Sequence
from typing import Any, Dict, Final, Optional

# Fully qualified to avoid circular import
import rerun.log.extension_components
from rerun import bindings
from rerun.components.color import ColorRGBAArray
from rerun.components.instance import InstanceArray
from rerun.components.text_entry import TextEntryArray
from rerun.log import _normalize_colors
from rerun.log import Color, _normalize_colors
from rerun.log.log_decorator import log_decorator
from rerun.log.text_internal import LogLevel

Expand Down Expand Up @@ -71,7 +71,7 @@ def log_text_entry(
text: str,
*,
level: Optional[str] = LogLevel.INFO,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
ext: Optional[Dict[str, Any]] = None,
timeless: bool = False,
) -> None:
Expand All @@ -89,7 +89,7 @@ def log_text_entry(
be an arbitrary string, but it's recommended to use one of the constants
from [LogLevel][rerun.log.text.LogLevel]
color:
Optional RGB or RGBA triplet in 0-255 sRGB.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
ext:
Optional dictionary of extension components. See [rerun.log_extension_components][]
timeless:
Expand Down
8 changes: 4 additions & 4 deletions rerun_py/rerun_sdk/rerun/log/text_internal.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
from dataclasses import dataclass
from typing import Any, Dict, Final, Optional, Sequence
from typing import Any, Dict, Final, Optional

# Fully qualified to avoid circular import
from rerun import bindings
from rerun.components.color import ColorRGBAArray
from rerun.components.instance import InstanceArray
from rerun.components.text_entry import TextEntryArray
from rerun.log import _normalize_colors
from rerun.log import Color, _normalize_colors

__all__ = [
"LogLevel",
Expand Down Expand Up @@ -48,7 +48,7 @@ def log_text_entry_internal(
text: str,
*,
level: Optional[str] = LogLevel.INFO,
color: Optional[Sequence[int]] = None,
color: Optional[Color] = None,
timeless: bool = False,
) -> None:
"""
Expand All @@ -68,7 +68,7 @@ def log_text_entry_internal(
be an arbitrary string, but it's recommended to use one of the constants
from [LogLevel][rerun.log.text.LogLevel]
color:
Optional RGB or RGBA triplet in 0-255 sRGB.
Optional RGB or RGBA in either 0-1 float, or 0-255 integer sRGB.
timeless:
Whether the text entry should be timeless.

Expand Down