Skip to content

Commit

Permalink
Merge pull request #11 from Nfsaavedra/fix_show
Browse files Browse the repository at this point in the history
fix issue with report's show arguments
  • Loading branch information
maximtrp authored Aug 14, 2024
2 parents 3997ee9 + 5cd99ad commit 24e48c5
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/tmplot/_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,29 @@ def report(
# Topic selection
def _on_select_topic(sel):
topic = sel['new']
topics_plot_output.clear_output(wait=False)
words_plot_output.clear_output(wait=False)
docs_plot_output.clear_output(wait=False)
with words_plot_output:
terms_probs = calc_terms_probs_ratio(
phi, topic=topic, lambda_=lambda_slider.value)
_words_kws.update({'terms_probs': terms_probs})
display(plot_terms(**_words_kws))
with topics_plot_output:
_topics_kws.update({'topic': topic})
display(plot_scatter_topics(**_topics_kws))
with docs_plot_output:
_top_docs_kws.update({'topics': [sel['new']]})
top_docs = get_top_docs(**_top_docs_kws)
top_docs.columns = ['']
_docs_kws.update({'docs': top_docs})
display(plot_docs(**_docs_kws))

if show_words:
words_plot_output.clear_output(wait=False)
with words_plot_output:
terms_probs = calc_terms_probs_ratio(
phi, topic=topic, lambda_=lambda_slider.value)
_words_kws.update({'terms_probs': terms_probs})
display(plot_terms(**_words_kws))

if show_topics:
topics_plot_output.clear_output(wait=False)
with topics_plot_output:
_topics_kws.update({'topic': topic})
display(plot_scatter_topics(**_topics_kws))

if show_docs:
docs_plot_output.clear_output(wait=False)
with docs_plot_output:
_top_docs_kws.update({'topics': [sel['new']]})
top_docs = get_top_docs(**_top_docs_kws)
top_docs.columns = ['']
_docs_kws.update({'docs': top_docs})
display(plot_docs(**_docs_kws))

topics_ids = list(range(len(_topics_kws['topics_coords'])))
topics_labels = topics_labels or topics_ids
Expand Down

0 comments on commit 24e48c5

Please sign in to comment.