Skip to content

Commit

Permalink
Issue google#356: Show first and last events instead of only first on…
Browse files Browse the repository at this point in the history
…es when displaying an EventSet
  • Loading branch information
jtaylor205 committed Jan 31, 2024
1 parent b585065 commit 025130a
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions temporian/implementation/numpy/data/display_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit 025130a

Please sign in to comment.