From 025130ac99809bddae0d4b5b3af3263bd40fef18 Mon Sep 17 00:00:00 2001 From: Jaedon Taylor Date: Tue, 30 Jan 2024 21:03:48 -0500 Subject: [PATCH] Issue #356: Show first and last events instead of only first ones when displaying an EventSet --- .../numpy/data/display_utils.py | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/temporian/implementation/numpy/data/display_utils.py b/temporian/implementation/numpy/data/display_utils.py index 7f2ccc5b9..e2a66e0cc 100644 --- a/temporian/implementation/numpy/data/display_utils.py +++ b/temporian/implementation/numpy/data/display_utils.py @@ -77,6 +77,9 @@ def display_html(evset: EventSet) -> str: index_data = evset.data[index_key] num_timestamps = len(index_data.timestamps) max_timestamps = config.display_max_events or num_timestamps + #Slices timestamps and features if there are more than 6 events + display_timestamps = np.concatenate((index_data.timestamps[:3], index_data.timestamps[-3:])) if num_timestamps > 6 else index_data.timestamps[:num_timestamps] + display_features = [np.concatenate((values[:3], values[-3:])) if num_timestamps > 6 else values for values in index_data.features] # Display index values html_index_value = html_div(dom) @@ -125,10 +128,9 @@ def display_html(evset: EventSet) -> str: # Rows with events for timestamp_idx, timestamp in enumerate( - index_data.timestamps[:max_timestamps] + display_timestamps ): row = [] - # Timestamp column timestamp_repr = ( convert_timestamp_to_datetime(timestamp) @@ -138,23 +140,19 @@ def display_html(evset: EventSet) -> str: row.append(f"{timestamp_repr}") # Feature values - for val, feature in zip( - index_data.features[:max_features], visible_feats - ): - row.append(repr_value_html(val[timestamp_idx], feature.dtype)) + for feature_idx, feature_schema in enumerate(visible_feats): + row.append(repr_value_html(display_features[feature_idx][timestamp_idx], feature_schema.dtype)) + # Add ... column on the right if has_hidden_feats: row.append(ELLIPSIS) - - # Create row and add - table.appendChild(html_table_row(dom, row)) - - # Add ... row at the bottom - if num_timestamps > max_timestamps: - # Timestamp + features + <... column if was added> - row = [ELLIPSIS] * (1 + len(visible_feats) + int(has_hidden_feats)) + + # Create ellipse row if more than 6 entries table.appendChild(html_table_row(dom, row)) + if timestamp_idx == 2 and num_timestamps > 6: + ellipsis_row = [ELLIPSIS] * (1 + len(visible_feats) + int(has_hidden_feats)) + table.appendChild(html_table_row(dom, ellipsis_row)) top.appendChild(table)