Skip to content

Commit

Permalink
add roundtrip test for points2d archetype (py)
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jul 4, 2023
1 parent af2c793 commit 25b7b2a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ screenshot*.png
web_demo

.nox/
out.rrd
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lint: toml-lint py-lint rs-lint

### Python

py_folders := "examples rerun_py scripts docs/code-examples"
py_folders := "docs/code-examples examples rerun_py scripts tests"

# Set up a Pythonvirtual environment for development
py-dev-env:
Expand Down
54 changes: 54 additions & 0 deletions tests/python/roundtrips/points2d/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3

from __future__ import annotations

import argparse
import itertools

import numpy as np
import rerun as rr
from rerun._rerun2 import components as rrc


def main() -> None:
points = np.array([1, 2, 3, 4], dtype=np.float32)
radii = np.array([0.42, 0.43], dtype=np.float32)
colors = np.array(
[
0xAA0000CC,
0x00BB00DD,
],
dtype=np.uint32,
)
labels = ["hello", "friend"]
draw_order = 300
class_ids = np.array([126, 127], dtype=np.uint64)
keypoint_ids = np.array([2, 3], dtype=np.uint64)
instance_keys = np.array([66, 666], dtype=np.uint64)

points2d = rr.Points2D(
points, # type: ignore[arg-type]
radii=radii, # type: ignore[arg-type]
colors=colors, # type: ignore[arg-type]
labels=labels, # type: ignore[arg-type]
draw_order=draw_order, # type: ignore[arg-type]
class_ids=class_ids, # type: ignore[arg-type]
keypoint_ids=keypoint_ids, # type: ignore[arg-type]
instance_keys=instance_keys, # type: ignore[arg-type]
)

parser = argparse.ArgumentParser(description="Logs rich data using the Rerun SDK.")
rr.script_add_args(parser)
args = parser.parse_args()

rr.script_setup(args, "roundtrip_points2d")

rr.log_any("points2d", points2d)
# Hack to establish 2d view bounds
rr.log_rect("rect", [0, 0, 4, 6])

rr.script_teardown(args)


if __name__ == "__main__":
main()

0 comments on commit 25b7b2a

Please sign in to comment.