Ejemplo n.º 1
0
    def get_markup(self):

        sections = []
        toc_lines = []

        warnings = self._get_warnings_table()
        if warnings:
            toc_lines.append(
                '- **[""Unexplained Errors"" #unexplained-errors]**')
            sections.append(('unexplained-errors', warnings))

        toc_lines.append('- **[""Info"" #info]**')
        sections.append(('info', self._get_general_info()))

        # Index of summary section.
        summary_index = len(sections)

        # Build a table containing summary functions of all other tables.
        # The actual section is added at position summary_index after creating
        # all other tables.
        if self.resolution in ['domain', 'combined']:
            summary = self._get_empty_table(title='summary')
            toc_lines.append('- **[""Summary"" #summary]**')

        for attribute in self.attributes:
            logging.info('Creating table(s) for %s' % attribute)
            tables = []
            if self.resolution in ['domain', 'combined']:
                if self.attribute_is_numeric(attribute):
                    domain_table = self._get_table(attribute)
                    tables.append(('', domain_table))
                    reports.extract_summary_rows(domain_table,
                                                 summary,
                                                 link='#' + attribute)
                else:
                    tables.append((
                        '', 'Domain-wise reports only support numeric '
                        'attributes, but %s has type %s.' %
                        (attribute, self._all_attributes[attribute].__name__)))
            if self.resolution in ['problem', 'combined']:
                for domain in sorted(self.domains.keys()):
                    # add table according to attribute type (this is the only change in get_markup vs the parent
                    if attribute != 'statistics' and attribute != 'commualtive_hstar_to_h':
                        tables.append(
                            (domain, self._get_table(attribute, domain)))
                    if attribute == 'statistics':
                        tables.append(
                            (domain,
                             self._get_statistics_table(attribute, domain)))
                    if attribute == 'commualtive_hstar_to_h':
                        tables.append(
                            (domain, self._get_commulative_table(domain)))

                parts = []
            toc_line = []
            for (domain, table) in tables:
                if domain:
                    assert table
                    toc_line.append(
                        '[""%(domain)s"" #%(attribute)s-%(domain)s]' %
                        locals())
                    parts.append('== %(domain)s ==[%(attribute)s-%(domain)s]\n'
                                 '%(table)s\n' % locals())
                else:
                    if table:
                        parts.append('%(table)s\n' % locals())
                    else:
                        parts.append(
                            'No task was found where all configurations '
                            'have a value for "%s". Therefore no '
                            'domain-wise table can be generated.\n' %
                            attribute)

            toc_lines.append('- **[""%s"" #%s]**' % (attribute, attribute))
            toc_lines.append('  - ' + ' '.join(toc_line))
            sections.append((attribute, '\n'.join(parts)))

        # Add summary before main content. This is done after creating the main content
        # because the summary table is extracted from all other tables.
        if self.resolution in ['domain', 'combined']:
            sections.insert(summary_index, ('summary', summary))

        if self.resolution == 'domain':
            toc = '- ' + ' '.join('[""%s"" #%s]' % (attr, attr)
                                  for (attr, section) in sections)
        else:
            toc = '\n'.join(toc_lines)

        content = '\n'.join('= %s =[%s]\n\n%s' % (attr, attr, section)
                            for (attr, section) in sections)
        return '%s\n\n\n%s' % (toc, content)
Ejemplo n.º 2
0
    def get_markup(self):
        sections = []
        toc_lines = []

        warnings = self._get_warnings_text_and_table()
        if warnings:
            toc_lines.append('- **['
                             'Unexplained Errors'
                             ' #unexplained-errors]**')
            sections.append(('unexplained-errors', warnings))

        toc_lines.append('- **[Info #info]**')
        sections.append(('info', self._get_general_info()))

        # Index of summary section.
        summary_index = len(sections)

        # Build a table containing summary functions of all other tables.
        # The actual section is added at position summary_index after creating
        # all other tables.
        summary = self._get_empty_table(title='Summary')
        summary.colored = self.colored
        toc_lines.append('- **[Summary #summary]**')

        for attribute in self.attributes:
            logging.info('Creating table(s) for %s' % attribute)
            tables = []
            if attribute == 'error':
                seen_errors = set()
                error_counter = defaultdict(int)

                for run in self.runs.values():
                    error = run.get('error', 'attribute-error-missing')
                    seen_errors.add(error)
                    error_counter[(run["algorithm"], run["domain"],
                                   error)] += 1

                error_to_min_wins = {
                    outcome.msg: outcome.min_wins
                    for outcome in outcomes.OUTCOMES
                }

                for error in sorted(seen_errors):
                    # Txt2tags seems to only allow letters, "-" and "_" in anchors.
                    pseudo_attribute = 'error-' + error
                    table = self._get_empty_table(title=pseudo_attribute)
                    min_wins = error_to_min_wins.get(error, None)
                    table.min_wins = min_wins
                    table.colored = min_wins is not None
                    for domain in self.domains:
                        if self.use_domain_links:
                            table.cell_formatters[domain][
                                table.header_column] = (reports.CellFormatter(
                                    link='#error-{domain}'.format(**locals())))
                        for algorithm in self.algorithms:
                            count = error_counter.get(
                                (algorithm, domain, error), 0)
                            table.add_cell(domain, algorithm, count)
                    table.add_summary_function('Sum', sum)
                    reports.extract_summary_rows(table,
                                                 summary,
                                                 link='#' + 'error-' +
                                                 pseudo_attribute)
                    tables.append((pseudo_attribute, table))
            elif self.attribute_is_numeric(attribute):
                domain_table = self._get_table(attribute)
                tables.append(('', domain_table))
                reports.extract_summary_rows(domain_table,
                                             summary,
                                             link='#' + attribute)
            else:
                tables.append(
                    ('', 'Domain-wise reports only support numeric '
                     'attributes, but %s has type %s.' %
                     (attribute, self._all_attributes[attribute].__name__)))
            for domain in sorted(self.domains.keys()):
                tables.append((domain, self._get_table(attribute, domain)))

            parts = []
            toc_line = []
            for (domain, table) in tables:
                if domain:
                    assert table
                    toc_line.append(
                        "[''%(domain)s'' #%(attribute)s-%(domain)s]" %
                        locals())
                    parts.append('== %(domain)s ==[%(attribute)s-%(domain)s]\n'
                                 '%(table)s\n' % locals())
                else:
                    if table:
                        parts.append('%(table)s\n' % locals())
                    else:
                        parts.append('No task was found where all algorithms '
                                     'have a value for "%s". Therefore no '
                                     'domain-wise table can be generated.\n' %
                                     attribute)

            toc_lines.append("- **[''{}'' #{}]**".format(attribute, attribute))
            toc_lines.append('  - ' + ' '.join(toc_line))
            sections.append((attribute, '\n'.join(parts)))

        # Add summary before main content. This is done after creating the main content
        # because the summary table is extracted from all other tables.
        sections.insert(summary_index, ('summary', summary))

        toc = '\n'.join(toc_lines)

        content = '\n'.join('= {} =[{}]\n\n{}'.format(attr, attr, section)
                            for (attr, section) in sections)
        return '{}\n\n\n{}'.format(toc, content)
Ejemplo n.º 3
0
    def get_markup(self):
        sections = []
        toc_lines = []

        warnings = self._get_warnings_text_and_table()
        if warnings:
            toc_lines.append("- **["
                             "Unexplained Errors"
                             " #unexplained-errors]**")
            sections.append(("unexplained-errors", warnings))

        toc_lines.append("- **[Info #info]**")
        sections.append(("info", self._get_general_info()))

        # Index of summary section.
        summary_index = len(sections)

        # Build a table containing summary functions of all other tables.
        # The actual section is added at position summary_index after creating
        # all other tables.
        summary = self._get_empty_table(title="Summary")
        summary.colored = self.colored
        toc_lines.append("- **[Summary #summary]**")

        for attribute in self.attributes:
            logging.info(f"Creating table(s) for {attribute}")
            tables = []
            if attribute == "error":
                seen_errors = set()
                error_counter = defaultdict(int)

                for run in self.runs.values():
                    error = run.get("error", "attribute-error-missing")
                    seen_errors.add(error)
                    error_counter[(run["algorithm"], run["domain"],
                                   error)] += 1

                error_to_min_wins = {
                    outcome.msg: outcome.min_wins
                    for outcome in outcomes.OUTCOMES
                }

                for error in sorted(seen_errors):
                    # Txt2tags seems to only allow letters, "-" and "_" in anchors.
                    pseudo_attribute = "error-" + error
                    table = self._get_empty_table(title=pseudo_attribute)
                    min_wins = error_to_min_wins.get(error, None)
                    table.min_wins = min_wins
                    table.colored = min_wins is not None
                    for domain in self.domains:
                        if self.use_domain_links:
                            table.cell_formatters[domain][
                                table.header_column] = reports.CellFormatter(
                                    link=f"#error-{domain}")
                        for algorithm in self.algorithms:
                            count = error_counter.get(
                                (algorithm, domain, error), 0)
                            table.add_cell(domain, algorithm, count)
                    table.add_summary_function("Sum", sum)
                    reports.extract_summary_rows(table,
                                                 summary,
                                                 link="#" + "error-" +
                                                 pseudo_attribute)
                    tables.append((pseudo_attribute, table))
            elif self.attribute_is_numeric(attribute):
                domain_table = self._get_suite_table(attribute)
                tables.append(("", domain_table))
                reports.extract_summary_rows(domain_table,
                                             summary,
                                             link="#" + attribute)
            else:
                tables.append((
                    "",
                    f"Domain-wise reports only support numeric "
                    f"attributes, but {attribute} has type "
                    f"{self._all_attributes[attribute].__name__}.",
                ))
            for domain in sorted(self.domains.keys()):
                tables.append(
                    (domain, self._get_domain_table(attribute, domain)))

            parts = []
            toc_line = []
            for (domain, table) in tables:
                if domain:
                    assert table
                    toc_line.append(f"[''{domain}'' #{attribute}-{domain}]")
                    parts.append(
                        f"== {domain} ==[{attribute}-{domain}]\n{table}\n")
                else:
                    if table:
                        parts.append(f"{table}\n")
                    else:
                        parts.append(
                            f"No task was found where all algorithms "
                            f'have a value for "{attribute}". Therefore no '
                            f"domain-wise table can be generated.\n")

            toc_lines.append(f"- **[''{attribute}'' #{attribute}]**")
            toc_lines.append("  - " + " ".join(toc_line))
            sections.append((attribute, "\n".join(parts)))

        # Add summary before main content. This is done after creating the main content
        # because the summary table is extracted from all other tables.
        sections.insert(summary_index, ("summary", summary))

        toc = "\n".join(toc_lines)

        content = "\n".join(f"= {attr} =[{attr}]\n\n{section}"
                            for (attr, section) in sections)
        return f"{toc}\n\n\n{content}"
Ejemplo n.º 4
0
    def get_markup(self):
        sections = []
        toc_lines = []

        warnings = self._get_warnings_table()
        if warnings:
            toc_lines.append('- **[""Unexplained Errors"" #unexplained-errors]**')
            sections.append(("unexplained-errors", warnings))

        toc_lines.append('- **[""Info"" #info]**')
        sections.append(("info", self._get_general_info()))

        # Index of summary section.
        summary_index = len(sections)

        # Build a table containing summary functions of all other tables.
        # The actual section is added at position summary_index after creating
        # all other tables.
        if self.resolution in ["domain", "combined"]:
            summary = self._get_empty_table(title="summary")
            toc_lines.append('- **[""Summary"" #summary]**')

        for attribute in self.attributes:
            logging.info("Creating table(s) for %s" % attribute)
            tables = []
            if self.resolution in ["domain", "combined"]:
                if self.attribute_is_numeric(attribute):
                    domain_table = self._get_table(attribute)
                    tables.append(("", domain_table))
                    reports.extract_summary_rows(domain_table, summary, link="#" + attribute)
                else:
                    tables.append(
                        (
                            "",
                            "Domain-wise reports only support numeric "
                            "attributes, but %s has type %s." % (attribute, self._all_attributes[attribute].__name__),
                        )
                    )
            if self.resolution in ["problem", "combined"]:
                for domain in sorted(self.domains.keys()):
                    tables.append((domain, self._get_table(attribute, domain)))

            parts = []
            toc_line = []
            for (domain, table) in tables:
                if domain:
                    assert table
                    toc_line.append('[""%(domain)s"" #%(attribute)s-%(domain)s]' % locals())
                    parts.append("== %(domain)s ==[%(attribute)s-%(domain)s]\n" "%(table)s\n" % locals())
                else:
                    if table:
                        parts.append("%(table)s\n" % locals())
                    else:
                        parts.append(
                            "No task was found where all configurations "
                            'have a value for "%s". Therefore no '
                            "domain-wise table can be generated.\n" % attribute
                        )

            toc_lines.append('- **[""%s"" #%s]**' % (attribute, attribute))
            toc_lines.append("  - " + " ".join(toc_line))
            sections.append((attribute, "\n".join(parts)))

        # Add summary before main content. This is done after creating the main content
        # because the summary table is extracted from all other tables.
        if self.resolution in ["domain", "combined"]:
            sections.insert(summary_index, ("summary", summary))

        if self.resolution == "domain":
            toc = "- " + " ".join('[""%s"" #%s]' % (attr, attr) for (attr, section) in sections)
        else:
            toc = "\n".join(toc_lines)

        content = "\n".join("= %s =[%s]\n\n%s" % (attr, attr, section) for (attr, section) in sections)
        return "%s\n\n\n%s" % (toc, content)
Ejemplo n.º 5
0
    def get_markup(self):

        sections = []
        toc_lines = []

        warnings = self._get_warnings_table()
        if warnings:
            toc_lines.append('- **[""Unexplained Errors"" #unexplained-errors]**')
            sections.append(('unexplained-errors', warnings))

        toc_lines.append('- **[""Info"" #info]**')
        sections.append(('info', self._get_general_info()))

        # Index of summary section.
        summary_index = len(sections)

        # Build a table containing summary functions of all other tables.
        # The actual section is added at position summary_index after creating
        # all other tables.
        if self.resolution in ['domain', 'combined']:
            summary = self._get_empty_table(title='summary')
            toc_lines.append('- **[""Summary"" #summary]**')

        for attribute in self.attributes:
            logging.info('Creating table(s) for %s' % attribute)
            tables = []
            if self.resolution in ['domain', 'combined']:
                if self.attribute_is_numeric(attribute):
                    domain_table = self._get_table(attribute)
                    tables.append(('', domain_table))
                    reports.extract_summary_rows(domain_table, summary, link='#' + attribute)
                else:
                    tables.append(('', 'Domain-wise reports only support numeric '
                        'attributes, but %s has type %s.' %
                        (attribute, self._all_attributes[attribute].__name__)))
            if self.resolution in ['problem', 'combined']:
                for domain in sorted(self.domains.keys()):
                    # add table according to attribute type (this is the only change in get_markup vs the parent
                    if attribute != 'statistics' and attribute != 'commualtive_hstar_to_h':
                        tables.append((domain, self._get_table(attribute, domain)))
                if attribute == 'statistics':
                    tables.append((domain, self._get_statistics_table(attribute, domain)))
                if attribute == 'commualtive_hstar_to_h':
                    tables.append((domain, self._get_commulative_table(domain)))

                parts = []
            toc_line = []
            for (domain, table) in tables:
                if domain:
                    assert table
                    toc_line.append('[""%(domain)s"" #%(attribute)s-%(domain)s]' %
                                    locals())
                    parts.append('== %(domain)s ==[%(attribute)s-%(domain)s]\n'
                                 '%(table)s\n' % locals())
                else:
                    if table:
                        parts.append('%(table)s\n' % locals())
                    else:
                        parts.append('No task was found where all configurations '
                                     'have a value for "%s". Therefore no '
                                     'domain-wise table can be generated.\n' %
                                     attribute)

            toc_lines.append('- **[""%s"" #%s]**' % (attribute, attribute))
            toc_lines.append('  - ' + ' '.join(toc_line))
            sections.append((attribute, '\n'.join(parts)))

        # Add summary before main content. This is done after creating the main content
        # because the summary table is extracted from all other tables.
        if self.resolution in ['domain', 'combined']:
            sections.insert(summary_index, ('summary', summary))

        if self.resolution == 'domain':
            toc = '- ' + ' '.join('[""%s"" #%s]' % (attr, attr)
                                  for (attr, section) in sections)
        else:
            toc = '\n'.join(toc_lines)

        content = '\n'.join('= %s =[%s]\n\n%s' % (attr, attr, section)
                            for (attr, section) in sections)
        return '%s\n\n\n%s' % (toc, content)