def update()

in widgets/zipf.py [0:0]


    def update(self, dstats: dmt_cls):
        z = dstats.z
        zipf_fig = dstats.zipf_fig

        zipf_summary = (
            "The optimal alpha based on this dataset is: **"
            + str(round(z.alpha, 2))
            + "**, with a KS distance of: **"
            + str(round(z.ks_distance, 2))
        )
        zipf_summary += (
            "**.  This was fit with a minimum rank value of: **"
            + str(int(z.xmin))
            + "**, which is the optimal rank *beyond which* the scaling regime of the power law fits best."
        )

        fit_results_table = pd.DataFrame.from_dict(
            {
                r"Alpha:": [str("%.2f" % z.alpha)],
                "KS distance:": [str("%.2f" % z.ks_distance)],
                "Min rank:": [str("%s" % int(z.xmin))],
            },
            columns=["Results"],
            orient="index",
        )
        fit_results_table.index.name = ""

        output = {
            self.zipf_table: fit_results_table,
            self.zipf_summary: zipf_summary,
            self.zipf_plot: zipf_fig,
            self.alpha_warning: gr.Markdown.update(visible=False),
            self.xmin_warning: gr.Markdown.update(visible=False),
        }
        if z.alpha > 2:
            output[self.alpha_warning] = gr.Markdown.update(visible=True)
        if z.xmin > 5:
            output[self.xmin_warning] = gr.Markdown.update(visible=True)
        return output