Skip to content

Commit

Permalink
Fix type hints and docstrings for fiel_filter() methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
carschno committed Dec 3, 2024
1 parent aed292e commit c6fb49f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tempo_embeddings/visualization/jscatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ def _show_top_words(b):

def _category_field_filter(
self, field: str
) -> Optional[tuple[widgets.SelectMultiple, widgets.Output]]:
) -> Optional[widgets.SelectMultiple]:
"""Create a selection widget for filtering on a categorical field.
Args:
field (str): The field to filter on.
Returns:
widgets.VBox: A widget containing the selection widget and the output widget
widgets.SelectMultiple: A widget containing the selection widget or None if the field is not suitable for filtering.
"""
# FIXME: this does not work for filtering by "top words"

Expand All @@ -324,22 +324,21 @@ def handle_change(change):

selector.observe(handle_change, names="value")

return selector
widget = selector
else:
logging.info(
f"Skipping field {field} with {len(options)} option(s) for filtering."
)
return
widget = None
return widget

def _continuous_field_filter(
self, field: str
) -> Optional[tuple[widgets.SelectionRangeSlider, widgets.Output]]:
def _continuous_field_filter(self, field: str) -> widgets.SelectionRangeSlider:
"""Create a selection widget for filtering on a continuous field.
Args:
field (str): The field to filter on.
Returns:
widgets.VBox: A widget containing a RangeSlider widget and the output widget
widgets.SelectionRangeSlider: A widget containing a RangeSlider
"""
if field not in self._df.columns:
raise ValueError(f"Field '{field}' not found.")
Expand Down

0 comments on commit c6fb49f

Please sign in to comment.