-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support displaying 1D tensors (#5837)
### What Technically two separate fixes: * visualizability for 1 x n and n x 1 was blocked * real single dimension tensors are now supported Test code: ```py import rerun as rr import numpy as np rr.init("1dtensor", spawn=True) x = np.linspace(0.0, 100.0, 100) rr.log("n", rr.Tensor(x)) rr.log("n_x_1", rr.Tensor(np.reshape(x, (100, 1)))) rr.log("1_x_n", rr.Tensor(np.reshape(x, (1, 100)))) ``` Before: <img width="1683" alt="Screenshot 2024-04-08 at 10 00 40" src="https://github.com/rerun-io/rerun/assets/1220815/2f2850dd-2d17-40af-ab3b-d5b86fa20f04"> After first commit: <img width="1698" alt="Screenshot 2024-04-08 at 10 02 53" src="https://github.com/rerun-io/rerun/assets/1220815/ae4108f2-199e-4c92-9575-13d232146efd"> After second commit: https://github.com/rerun-io/rerun/assets/1220815/18b3fc7a-c0d6-4fff-8d3d-ab7d26d5d2fe ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using newly built examples: [rerun.io/viewer](https://rerun.io/viewer/pr/5837) * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5837?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5837?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/5837) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
- Loading branch information
Showing
6 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from argparse import Namespace | ||
from uuid import uuid4 | ||
|
||
import numpy as np | ||
import rerun as rr | ||
|
||
README = """ | ||
# 1D Image/Tensor/BarChart | ||
This checks the different ways 1D arrays can be visualized. | ||
### Actions | ||
You should see: | ||
* a tensor view with 1D data | ||
* an image view with a 1D image | ||
* a bar chart | ||
Bonus actions: | ||
* use the ui to create a tensor/bar-chart with each of the entities no matter how it was logged | ||
* TODO(#5847): Right now tensors & bar charts can not be reinterpreted as 2D images. | ||
In this example, image is correctly not suggested for the `tensor` and `image` entities, | ||
since they are of 1D shape, but this would be relevant if they were 1xN or Nx1. | ||
""" | ||
|
||
|
||
def log_readme() -> None: | ||
rr.log("readme", rr.TextDocument(README, media_type=rr.MediaType.MARKDOWN), timeless=True) | ||
|
||
|
||
def log_1d_data() -> None: | ||
x = np.linspace(0.0, 100.0, 100) | ||
rr.log("tensor", rr.Tensor(x)) | ||
rr.log("barchart", rr.BarChart(x)) | ||
# We're not allowing "real" 1D here and force users to be explicit about width/height | ||
rr.log("image", rr.Image(np.reshape(x, (1, 100)))) | ||
|
||
|
||
def run(args: Namespace) -> None: | ||
rr.script_setup(args, f"{os.path.basename(__file__)}", recording_id=uuid4()) | ||
|
||
log_readme() | ||
log_1d_data() | ||
|
||
|
||
if __name__ == "__main__": | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description="Interactive release checklist") | ||
rr.script_add_args(parser) | ||
args = parser.parse_args() | ||
run(args) |