Skip to content

Commit

Permalink
Use "N-dimensional" instead of "rank-N" in docstrings and error messa…
Browse files Browse the repository at this point in the history
…ges (#6797)

### What
* Closes #5254

### 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 examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/{{pr.number}}?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/{{pr.number}}?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/{{pr.number}})
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
emilk authored and abey79 committed Jul 8, 2024
1 parent 6910c26 commit e952571
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 52 deletions.
2 changes: 1 addition & 1 deletion crates/re_types/definitions/rerun/archetypes/bar_chart.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ table BarChart (
) {
// --- Required ---

/// The values. Should always be a rank-1 tensor.
/// The values. Should always be a 1-dimensional tensor (i.e. a vector).
values: rerun.components.TensorData ("attr.rerun.component_required", required, order: 1000);

// --- Optional ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ table DepthImage (
) {
// --- Required ---

/// The depth-image data. Should always be a rank-2 tensor.
/// The depth-image data. Should always be a 2-dimensional tensor.
data: rerun.components.TensorData ("attr.rerun.component_required", order: 1000);

// --- Optional ---
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/definitions/rerun/archetypes/image.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ table Image (
) {
// --- Required ---

/// The image data. Should always be a rank-2 or rank-3 tensor.
/// The image data. Should always be a 2- or 3-dimensional tensor.
data: rerun.components.TensorData ("attr.rerun.component_required", order: 1000);

// --- Optional ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ table SegmentationImage (
) {
// --- Required ---

/// The image data. Should always be a rank-2 tensor.
/// The image data. Should always be a 2-dimensional tensor.
data: rerun.components.TensorData ("attr.rerun.component_required", order: 1000);

// --- Optional ---
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/bar_chart.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/depth_image.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/image.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/archetypes/segmentation_image.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rerun_cpp/src/rerun/archetypes/bar_chart.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions rerun_cpp/src/rerun/archetypes/depth_image.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions rerun_cpp/src/rerun/archetypes/depth_image_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "../collection_adapter_builtins.hpp"

#include <sstream>

namespace rerun::archetypes {

#ifdef EDIT_EXTENSION
Expand All @@ -11,7 +13,7 @@ namespace rerun::archetypes {
/// New depth image from height/width and tensor buffer.
///
/// \param shape
/// Shape of the image. Calls `Error::handle()` if the shape is not rank 2.
/// Shape of the image. Calls `Error::handle()` if the tensor is not 2-dimensional
/// Sets the dimension names to "height" and "width" if they are not specified.
/// \param buffer
/// The tensor buffer containing the depth image data.
Expand All @@ -23,14 +25,14 @@ namespace rerun::archetypes {
/// \param data_
/// The tensor buffer containing the depth image data.
/// Sets the dimension names to "height" and "width" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2.
/// Calls `Error::handle()` if the tensor is not 2-dimensional
explicit DepthImage(components::TensorData data_);

/// New depth image from dimensions and pointer to depth image data.
///
/// Type must be one of the types supported by `rerun::datatypes::TensorData`.
/// \param shape
/// Shape of the image. Calls `Error::handle()` if the shape is not rank 2.
/// Shape of the image. Calls `Error::handle()` if the tensor is not 2-dimensional
/// Sets the dimension names to "height", "width" and "channel" if they are not specified.
/// Determines the number of elements expected to be in `data`.
/// \param data_
Expand All @@ -45,7 +47,9 @@ namespace rerun::archetypes {
DepthImage::DepthImage(components::TensorData data_) : data(std::move(data_)) {
auto& shape = data.data.shape;
if (shape.size() != 2) {
Error(ErrorCode::InvalidTensorDimension, "Shape must be rank 2.").handle();
std::stringstream ss;
ss << "Expected 2-dimensional tensor, got " << shape.size() << " dimensions.";
Error(ErrorCode::InvalidTensorDimension, ss.str()).handle();
return;
}

Expand Down
8 changes: 4 additions & 4 deletions rerun_cpp/src/rerun/archetypes/image.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions rerun_cpp/src/rerun/archetypes/image_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "../collection_adapter_builtins.hpp"

#include <sstream>

// Uncomment for better auto-complete while editing the extension.
// #define EDIT_EXTENSION

Expand All @@ -14,7 +16,7 @@ namespace rerun::archetypes {
/// New Image from height/width/channel and tensor buffer.
///
/// \param shape
/// Shape of the image. Calls `Error::handle()` if the shape is not rank 2 or 3.
/// Shape of the image. Calls `Error::handle()` if the tensor is not 2- or 3-dimensional.
/// Sets the dimension names to "height", "width" and "channel" if they are not specified.
/// \param buffer
/// The tensor buffer containing the image data.
Expand All @@ -26,14 +28,14 @@ namespace rerun::archetypes {
/// \param data_
/// The tensor buffer containing the image data.
/// Sets the dimension names to "height", "width" and "channel" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2 or 3.
/// Calls `Error::handle()` if the tensor is not 2- or 3-dimensional.
explicit Image(rerun::components::TensorData data_);

/// New image from dimensions and pointer to image data.
///
/// Type must be one of the types supported by `rerun::datatypes::TensorData`.
/// \param shape
/// Shape of the image. Calls `Error::handle()` if the shape is not rank 2 or 3.
/// Shape of the image. Calls `Error::handle()` if the tensor is not 2- or 3-dimensional.
/// Sets the dimension names to "height", "width" and "channel" if they are not specified.
/// Determines the number of elements expected to be in `data`.
/// \param data_
Expand All @@ -48,11 +50,9 @@ namespace rerun::archetypes {
Image::Image(rerun::components::TensorData data_) : data(std::move(data_)) {
auto& shape = data.data.shape;
if (shape.size() != 2 && shape.size() != 3) {
Error(
ErrorCode::InvalidTensorDimension,
"Image shape is expected to be either rank 2 or 3."
)
.handle();
std::stringstream ss;
ss << "Expected 2- or 3-dimensional tensor, got " << shape.size() << " dimensions.";
Error(ErrorCode::InvalidTensorDimension, ss.str()).handle();
return;
}
if (shape.size() == 3 && shape[2].size != 1 && shape[2].size != 3 && shape[2].size != 4) {
Expand Down
8 changes: 4 additions & 4 deletions rerun_cpp/src/rerun/archetypes/segmentation_image.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions rerun_cpp/src/rerun/archetypes/segmentation_image_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "../collection_adapter_builtins.hpp"
#include "../error.hpp"

#include <sstream>

namespace rerun::archetypes {

#if 0
Expand All @@ -11,7 +13,7 @@ namespace rerun::archetypes {
/// New segmentation image from height/width and tensor buffer.
///
/// \param shape
/// Shape of the image. Calls `Error::handle()` if the shape is not rank 2.
/// Shape of the image. Calls `Error::handle()` if the tensor is not 2-dimensional
/// Sets the dimension names to "height" and "width" if they are not specified.
/// \param buffer
/// The tensor buffer containing the segmentation image data.
Expand All @@ -23,14 +25,14 @@ namespace rerun::archetypes {
/// \param data_
/// The tensor buffer containing the segmentation image data.
/// Sets the dimension names to "height" and "width" if they are not specified.
/// Calls `Error::handle()` if the shape is not rank 2.
/// Calls `Error::handle()` if the tensor is not 2-dimensional
explicit SegmentationImage(components::TensorData data_);

/// New segmentation image from dimensions and pointer to segmentation image data.
///
/// Type must be one of the types supported by `rerun::datatypes::TensorData`.
/// \param shape
/// Shape of the image. Calls `Error::handle()` if the shape is not rank 2.
/// Shape of the image. Calls `Error::handle()` if the tensor is not 2-dimensional
/// Sets the dimension names to "height", "width" and "channel" if they are not specified.
/// Determines the number of elements expected to be in `data`.
/// \param data_
Expand All @@ -45,7 +47,9 @@ namespace rerun::archetypes {
SegmentationImage::SegmentationImage(components::TensorData data_) : data(std::move(data_)) {
auto& shape = data.data.shape;
if (shape.size() != 2) {
Error(ErrorCode::InvalidTensorDimension, "Shape must be rank 2.").handle();
std::stringstream ss;
ss << "Expected 2-dimensional tensor, got " << shape.size() << " dimensions.";
Error(ErrorCode::InvalidTensorDimension, ss.str()).handle();
return;
}

Expand Down
10 changes: 5 additions & 5 deletions rerun_cpp/tests/archetypes/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace rerun::archetypes;
#define TEST_TAG "[image][archetypes]"

SCENARIO("Image archetype can be created from tensor data." TEST_TAG) {
GIVEN("tensor data with correct rank 2 shape") {
GIVEN("tensor data with correct 2-dimensional shape") {
rerun::datatypes::TensorData data({3, 7}, std::vector<uint8_t>(3 * 7, 0));
THEN("no error occurs on image construction") {
auto image = check_logged_error([&] { return Image(std::move(data)); });
Expand All @@ -22,7 +22,7 @@ SCENARIO("Image archetype can be created from tensor data." TEST_TAG) {
}
}
}
GIVEN("tensor data with correct rank 3 shape") {
GIVEN("tensor data with correct 3-dimensional shape") {
rerun::datatypes::TensorData data({3, 7, 3}, std::vector<uint8_t>(3 * 7 * 3, 0));
THEN("no error occurs on image construction") {
auto image = check_logged_error([&] { return Image(std::move(data)); });
Expand All @@ -38,7 +38,7 @@ SCENARIO("Image archetype can be created from tensor data." TEST_TAG) {
}
}
}
GIVEN("tensor data with incorrect rank 3 shape") {
GIVEN("tensor data with incorrect 3-dimensional shape") {
rerun::datatypes::TensorData data({3, 7, 2}, std::vector<uint8_t>(3 * 7 * 2, 0));
THEN("a warning occurs on image construction") {
auto image = check_logged_error(
Expand Down Expand Up @@ -72,7 +72,7 @@ SCENARIO("Image archetype can be created from tensor data." TEST_TAG) {
}
}

GIVEN("tensor data with too high rank") {
GIVEN("tensor data with too high dimensionality") {
rerun::datatypes::TensorData data(
{
{
Expand Down Expand Up @@ -103,7 +103,7 @@ SCENARIO("Image archetype can be created from tensor data." TEST_TAG) {
}
}

GIVEN("tensor data with too low rank") {
GIVEN("tensor data with too low dimensionality") {
rerun::datatypes::TensorData data(
{
rerun::datatypes::TensorDimension(1, "dr robotnik"),
Expand Down
4 changes: 2 additions & 2 deletions rerun_cpp/tests/archetypes/segmentation_and_depth_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void run_image_tests() {
}
}

GIVEN("tensor data with too high rank") {
GIVEN("tensor data with too high dimensionality") {
rerun::datatypes::TensorData data(
{
{
Expand Down Expand Up @@ -75,7 +75,7 @@ void run_image_tests() {
}
}

GIVEN("tensor data with too low rank") {
GIVEN("tensor data with too low dimensionality") {
rerun::datatypes::TensorData data(
{
rerun::datatypes::TensorDimension(1, "dr robotnik"),
Expand Down
Loading

0 comments on commit e952571

Please sign in to comment.