Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove manual truncation of tensor shape UI #8531

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions crates/viewer/re_data_ui/src/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,20 @@ use re_viewer_context::{TensorStats, TensorStatsCache, UiLayout, ViewerContext};
use super::EntityDataUi;

pub fn format_tensor_shape_single_line(shape: &[TensorDimension]) -> String {
const MAX_SHOWN: usize = 4; // should be enough for width/height/depth and then some!
let iter = shape.iter().take(MAX_SHOWN);
let iter = shape.iter();
let labelled = iter.clone().any(|dim| dim.name.is_some());
let shapes = iter
.map(|dim| {
format!(
"{}{}",
dim.size,
if let Some(name) = &dim.name {
format!(" ({name})")
} else {
String::new()
}
)
})
.join(if labelled { " × " } else { "×" });
format!(
"{shapes}{}",
if shape.len() > MAX_SHOWN {
if labelled {
" × …"
iter.map(|dim| {
format!(
"{}{}",
dim.size,
if let Some(name) = &dim.name {
format!(" ({name})")
} else {
"×…"
String::new()
}
} else {
""
}
)
)
})
.join(if labelled { " × " } else { "×" })
}

impl EntityDataUi for re_types::components::TensorData {
Expand Down
Loading