Skip to content

Commit

Permalink
Add Tab titles.
Browse files Browse the repository at this point in the history
  • Loading branch information
carschno committed Dec 5, 2024
1 parent d382a83 commit ef84352
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions tempo_embeddings/visualization/jscatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@ def __init__(self, corpora: list[Corpus], **kwargs):
self._visualizer = JScatterVisualizer(corpora, container=self, **kwargs)
"""The root visualizer."""

self.add_tab(self._visualizer, **kwargs)
self.add_tab(self._visualizer)

def add_tab(self, visualizer: list[Corpus], *, title: Optional[str] = None):
if title is None:
title = (
f"Clusters {len(self._tab.children)}"
if self._tab.children
else "Full Corpus"
)

self._tab.children = list(self._tab.children) + [
widgets.VBox(visualizer.get_widgets())
]

def add_tab(self, visualizer: list[Corpus], **kwargs):
children = list(self._tab.children)
children.append(widgets.VBox(visualizer.get_widgets()))
self._tab.children = children
self._tab.set_title(-1, title)
self._tab.selected_index = len(self._tab.children) - 1

def visualize(self):
display(self._tab)
Expand Down

0 comments on commit ef84352

Please sign in to comment.