Skip to content

Commit 4d8fcad

Browse files
authored
Replace list(zip(...)) with np.stack(..., axis=1) (#3768)
#3625 was already mostly addressed by #3620, but used `list(zip(...))` instead of `np.stack`. The latter seems like the better approach, since it avoids splitting up the array into lots of smaller arrays. So this is replacing the `list(zip(...))` pattern with `np.stack(..., axis=1)`. Closes #3625.
1 parent 9ad4f4e commit 4d8fcad

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

docs/content/getting-started/logging-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ We can represent the scaffolding using a batch of 3D line strips:
158158
```python
159159
rr.log(
160160
"dna/structure/scaffolding",
161-
rr.LineStrips3D(list(zip(points1, points2)), colors=[128, 128, 128])
161+
rr.LineStrips3D(np.stack(points1, points2, axis=1), colors=[128, 128, 128])
162162
)
163163
```
164164

examples/python/dna/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def log_data() -> None:
6060
rr.log("helix/structure/left", rr.Points3D(points1, colors=colors1, radii=0.08))
6161
rr.log("helix/structure/right", rr.Points3D(points2, colors=colors2, radii=0.08))
6262

63-
rr.log("helix/structure/scaffolding", rr.LineStrips3D(list(zip(points1, points2)), colors=[128, 128, 128]))
63+
rr.log("helix/structure/scaffolding", rr.LineStrips3D(np.stack((points1, points2), axis=1), colors=[128, 128, 128]))
6464

6565
time_offsets = np.random.rand(NUM_POINTS)
6666
for i in range(400):

rerun_py/rerun_sdk/rerun_demo/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def build_rect_pyramid(count=20, width=100, height=100):
8181
y = np.linspace(0, height, count)
8282
widths = np.linspace(float(width) / count, width, count)
8383
heights = 0.8 * np.ones(count) * height / count
84-
rects = np.array(list(zip(x, y, widths, heights)))
84+
rects = np.stack((x, y, widths, heights), axis=1)
8585
colors = turbo_colormap_data[np.linspace(0, len(turbo_colormap_data) - 1, count, dtype=int)]
8686

8787
return RectPyramid(rects, RectFormat.XCYCWH, colors)

0 commit comments

Comments
 (0)