(self)
Send report
Send report
Send report
def send_report(self):
        """Send report"""
        def _report_variables(variables):
            def was(n, o):
                return n if n == o else f"{n} (was: {o})"

            max_values = max(
                (len(var.values) for var in variables if var.is_discrete),
                default=1)

            rows = ""
            disc_dict = {k.var.name: k for k in self.disc_descs}
            cont_dict = {k.var.name: k for k in self.cont_descs}
            for var in variables:
                if var.is_discrete:
                    desc = disc_dict[var.name]
                    value_cols = "    \n".join(
                        f"<td>{square(*color)} {was(value, old_value)}</td>"
                        for color, value, old_value in
                        zip(desc.colors, desc.values, var.values))
                elif var.is_continuous:
                    desc = cont_dict[var.name]
                    pal = colorpalettes.ContinuousPalettes[desc.palette_name]
                    value_cols = f'<td colspan="{max_values}">' \
                                 f'{pal.friendly_name}</td>'
                else:
                    continue
                names = was(desc.name, desc.var.name)
                rows += '<tr style="height: 2em">\n' \
                        f'  <th style="text-align: right">{names}</th>' \
                        f'  {value_cols}\n' \
                        '</tr>\n'
            return rows

        if not self.data:
            return
        dom = self.data.domain
        sections = (
            (name, _report_variables(variables))
            for name, variables in (
                ("Features", dom.attributes),
                ("Outcome" + "s" * (len(dom.class_vars) > 1), dom.class_vars),
                ("Meta attributes", dom.metas)))
        table = "".join(f"<tr><th>{name}</th></tr>{rows}"
                        for name, rows in sections if rows)
        if table:
            self.report_raw(f"<table>{table}</table>")
def send_report ( self ) : def _report_variables ( variables ) : def was ( n , o ) : return n if n == o else f"{n} (was: {o})" max_values = max ( ( len ( var . values ) for var in variables if var . is_discrete ) , default = 1 ) rows = "" disc_dict = { k . var . name : k for k in self . disc_descs } cont_dict = { k . var . name : k for k in self . cont_descs } for var in variables : if var . is_discrete : desc = disc_dict [ var . name ] value_cols = "    \n" . join ( f"<td>{square(*color)} {was(value, old_value)}</td>" for color , value , old_value in zip ( desc . colors , desc . values , var . values ) ) elif var . is_continuous : desc = cont_dict [ var . name ] pal = colorpalettes . ContinuousPalettes [ desc . palette_name ] value_cols = f'<td colspan="{max_values}">' f'{pal.friendly_name}</td>' else : continue names = was ( desc . name , desc . var . name ) rows += '<tr style="height: 2em">\n' f'  <th style="text-align: right">{names}</th>' f'  {value_cols}\n' '</tr>\n' return rows if not self . data : return dom = self . data . domain sections = ( ( name , _report_variables ( variables ) ) for name , variables in ( ( "Features" , dom . attributes ) , ( "Outcome" + "s" * ( len ( dom . class_vars ) > 1 ) , dom . class_vars ) , ( "Meta attributes" , dom . metas ) ) ) table = "" . join ( f"<tr><th>{name}</th></tr>{rows}" for name , rows in sections if rows ) if table : self . report_raw ( f"<table>{table}</table>" )