From 5e2ea0dbe0892878ae9b4c08c07af20c7dc666c8 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Wed, 18 Dec 2024 14:52:56 +0100 Subject: [PATCH 1/2] Remove manual truncation of tensor shape UI Truncation now happens at egui test level. --- crates/viewer/re_data_ui/src/tensor.rs | 36 ++++++++------------------ 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/crates/viewer/re_data_ui/src/tensor.rs b/crates/viewer/re_data_ui/src/tensor.rs index afe680f47228..2e1dee57ecd8 100644 --- a/crates/viewer/re_data_ui/src/tensor.rs +++ b/crates/viewer/re_data_ui/src/tensor.rs @@ -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 { From 45c7118474d6c62b1c644612f2f386567d7b6f49 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Wed, 18 Dec 2024 15:07:42 +0100 Subject: [PATCH 2/2] post merge --- crates/viewer/re_data_ui/src/tensor.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/crates/viewer/re_data_ui/src/tensor.rs b/crates/viewer/re_data_ui/src/tensor.rs index badbb7f541b9..8d21b1c1d45c 100644 --- a/crates/viewer/re_data_ui/src/tensor.rs +++ b/crates/viewer/re_data_ui/src/tensor.rs @@ -9,13 +9,13 @@ use re_viewer_context::{TensorStats, TensorStatsCache, UiLayout, ViewerContext}; use super::EntityDataUi; fn format_tensor_shape_single_line(tensor: &TensorData) -> String { - const MAX_SHOWN: usize = 4; // should be enough for width/height/depth and then some! - let short_shape = &tensor.shape[0..tensor.shape.len().min(MAX_SHOWN)]; - let has_names = short_shape + let has_names = tensor + .shape .iter() .enumerate() .any(|(dim_idx, _)| tensor.dim_name(dim_idx).is_some()); - let shapes = short_shape + tensor + .shape .iter() .enumerate() .map(|(dim_idx, dim_len)| { @@ -29,19 +29,7 @@ fn format_tensor_shape_single_line(tensor: &TensorData) -> String { } ) }) - .join(if has_names { " × " } else { "×" }); - format!( - "{shapes}{}", - if MAX_SHOWN < tensor.shape.len() { - if has_names { - " × …" - } else { - "×…" - } - } else { - "" - } - ) + .join(if has_names { " × " } else { "×" }) } impl EntityDataUi for re_types::components::TensorData {