Skip to content

Commit 98a9f6b

Browse files
committed
Update doc & fix lints
1 parent 7a6ed9b commit 98a9f6b

File tree

8 files changed

+73
-4
lines changed

8 files changed

+73
-4
lines changed

docs/content/howto/logging/send-columns.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ snippet: archetypes/image_send_columns
2626

2727

2828
### Using `send_columns` for logging points
29-
Each row the in the component column can be a batch of data, e.g. a batch of positions.
29+
Each row in the component column can be a batch of data, e.g. a batch of positions.
3030
This lets you log the evolution of a point cloud over time efficiently.
3131

3232
snippet: archetypes/points3d_send_columns.py
33+
34+
### Using `send_columns` for logging custom components
35+
36+
An entire batch of a custom component can be logged at once using [`rr.AnyBatchValue`](https://ref.rerun.io/docs/python/0.20.0/common/custom_data/#rerun.AnyBatchValue?speculative-link) along with `send_column`:
37+
38+
snippet: howto/any_batch_value_send_columns
39+
40+
The [`rr.AnyValues`](https://ref.rerun.io/docs/python/0.20.0/common/custom_data/#rerun.AnyValues) class can also be used to log multiple components at a time.
41+
It does not support partitioning, so each component batch and the timeline must hold the same number of elements.
42+
43+
snippet: howto/any_values_send_columns
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Use `AnyBatchValue` and `send_column` to send an entire column of custom data to Rerun."""
2+
3+
from __future__ import annotations
4+
5+
import numpy as np
6+
import rerun as rr
7+
8+
rr.init("rerun_example_any_batch_value_send_columns", spawn=True)
9+
10+
N = 64
11+
timestamps = np.arange(0, N)
12+
one_per_timestamp = np.sin(timestamps / 10.0)
13+
ten_per_timestamp = np.cos(np.arange(0, N * 10) / 100.0)
14+
15+
rr.send_columns(
16+
"/",
17+
times=[rr.TimeSequenceColumn("step", timestamps)],
18+
components=[
19+
# log one value per timestamp
20+
rr.AnyBatchValue("custom_component_single", one_per_timestamp),
21+
# log ten values per timestamp
22+
rr.AnyBatchValue("custom_component_multi", ten_per_timestamp).partition([10] * N),
23+
],
24+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Use `AnyValues` and `send_column` to send entire columns of custom data to Rerun."""
2+
3+
from __future__ import annotations
4+
5+
import numpy as np
6+
import rerun as rr
7+
8+
rr.init("rerun_example_any_values_send_columns", spawn=True)
9+
10+
timestamps = np.arange(0, 64)
11+
12+
# Log two components, named "sin" and "cos", with the corresponding values
13+
values = rr.AnyValues(
14+
sin=np.sin(timestamps / 10.0),
15+
cos=np.cos(timestamps / 10.0),
16+
)
17+
18+
rr.send_columns(
19+
"/",
20+
times=[rr.TimeSequenceColumn("step", timestamps)],
21+
components=values.as_component_batches(),
22+
)

docs/snippets/snippets.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ views = [
6262
"archetypes/points3d_send_columns" = [
6363
"rust", # Doesn't support partitioned component batches yet.
6464
]
65+
"howto/any_batch_value_send_columns" = [
66+
"cpp", # Not implemented
67+
"rust", # Not implemented
68+
]
69+
"howto/any_values_send_columns" = [
70+
"cpp", # Not implemented
71+
"rust", # Not implemented
72+
]
6573
"migration/log_line" = [ # Not a complete example -- just a single log line
6674
"cpp",
6775
"rust",

rerun_py/docs/gen_common_index.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ class Section:
145145
),
146146
Section(
147147
title="Custom Data",
148-
class_list=["AnyValues"],
148+
class_list=[
149+
"AnyValues",
150+
"AnyBatchValues",
151+
],
149152
),
150153
################################################################################
151154
# These are tables but don't need their own pages since they refer to types that

rerun_py/rerun_sdk/rerun/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
send_columns as send_columns,
5858
)
5959
from .any_value import (
60+
AnyBatchValue as AnyBatchValue,
6061
AnyValues as AnyValues,
6162
)
6263
from .archetypes import (

rerun_py/rerun_sdk/rerun/_send_columns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def send_columns(
232232
array = c.as_arrow_array()
233233
if array is None:
234234
raise ValueError(f"Expected a non-null value for component: {component_name}")
235-
component_column = c.partition([1] * len(c.as_arrow_array()))
235+
component_column = c.partition([1] * len(c.as_arrow_array())) # type: ignore[arg-type]
236236
else:
237237
raise TypeError(
238238
f"Expected either a type that implements the `ComponentMixin` or a `ComponentColumn`, got: {type(c)}"

rerun_py/rerun_sdk/rerun/any_value.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,5 @@ def __init__(self, drop_untyped_nones: bool = True, **kwargs: Any) -> None:
186186
if batch.is_valid():
187187
self.component_batches.append(batch)
188188

189-
def as_component_batches(self) -> Iterable[AnyBatchValue]:
189+
def as_component_batches(self) -> Iterable[ComponentBatchLike]:
190190
return self.component_batches

0 commit comments

Comments
 (0)