in widgets/text_lengths.py [0:0]
def update(self, dstats: dmt_cls):
explainer_text = (
"The average length of text instances is **"
+ str(round(dstats.length_obj.avg_length, 2))
+ " words**, with a standard deviation of **"
+ str(round(dstats.length_obj.std_length, 2))
+ "**."
)
# TODO: Add text on choosing the length you want to the dropdown.
output = {
self.text_length_distribution_plot: dstats.length_obj.fig_lengths,
self.text_length_explainer: explainer_text,
}
if dstats.length_obj.lengths_df is not None:
import numpy as np
choices = np.sort(dstats.length_obj.lengths_df["length"].unique())[
::-1
].tolist()
output[self.text_length_drop_down] = gr.Dropdown.update(
choices=choices, value=choices[0]
)
output[self.text_length_df] = self.update_text_length_df(choices[0], dstats)
else:
output[self.text_length_df] = gr.update(visible=False)
output[self.text_length_drop_down] = gr.update(visible=False)
return output