Skip to content

Commit

Permalink
Remove manual truncation of tensor shape UI (#8531)
Browse files Browse the repository at this point in the history
### Related

* fixes #8525

### What

Truncation now happens at egui test level, so we no longer need that
manual truncation code. (This code is soon going to disappear anyways
but at least it'll disappear in a good state 🤷🏻)


![image](https://github.com/user-attachments/assets/ee8c0d00-1ff3-4e2c-8154-41c2e1c58bae)
  • Loading branch information
abey79 authored Dec 18, 2024
1 parent e10d5bc commit efcb2f5
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions crates/viewer/re_data_ui/src/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)| {
Expand All @@ -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 {
Expand Down

0 comments on commit efcb2f5

Please sign in to comment.