How to use the beautifultable.BeautifulTable function in beautifultable

To help you get started, we’ve selected a few beautifultable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cloud-CV / evalai-cli / tests / test_challenges.py View on Github external
def test_display_leaderboard(self):
        attributes = self.leaderboard[0]["leaderboard__schema"]["labels"]

        table = BeautifulTable(max_width=150)
        attributes = (
            ["Rank", "Participant Team"] + attributes + ["Last Submitted"]
        )
        attributes = list(map(lambda item: str(item), attributes))
        table.column_headers = attributes

        for rank, result in enumerate(self.leaderboard, start=1):
            name = result["submission__participant_team__team_name"]
            scores = result["result"]
            last_submitted = convert_UTC_date_to_local(
                result["submission__submitted_at"]
            )

            value = [rank, name] + scores + [last_submitted]
            table.append_row(value)
github Cloud-CV / evalai-cli / tests / test_teams.py View on Github external
def test_display_host_teams_list(self):
        table = BeautifulTable(max_width=200)
        attributes = ["id", "team_name", "created_by"]
        columns_attributes = [
            "ID",
            "Team Name",
            "Created By",
            "Members",
            "Team URL",
        ]
        table.column_headers = columns_attributes
        for team in self.host_teams:
            values = list(map(lambda item: team[item], attributes))
            members = ", ".join(
                map(lambda member: member["user"], team["members"])
            )
            values.append(members)
            if team["team_url"]:
github asharov / git-hammer / githammer / summary / table.py View on Github external
def _make_table(columns):
    table = BeautifulTable()
    table.set_style(BeautifulTable.STYLE_COMPACT)
    table.column_headers = columns
    for column in columns:
        if column == 'Author':
            table.column_alignments[column] = BeautifulTable.ALIGN_LEFT
        else:
            table.column_alignments[column] = BeautifulTable.ALIGN_RIGHT
    return table
github gdikov / hypertunity / hypertunity / reports / table.py View on Github external
primary_metric: str = "",
                 database_path: str = None):
        """Initialise the table reporter with domain and metrics.

        Args:
            domain: A :class:`Domain` from which all evaluated samples are drawn.
            metrics: :obj:`List[str]` with names of the metrics used during evaluation.
            primary_metric: (optional) :obj:`str` primary metric from `metrics`.
                This is used to determine the best sample. Defaults to the first one.
            database_path: (optional) :obj:`str` path to the database for
                storing experiment history on disk. Defaults to in-memory storage.
        """
        super(Table, self).__init__(
            domain, metrics, primary_metric, database_path
        )
        self._table = bt.BeautifulTable()
        self._table.set_style(bt.STYLE_SEPARATED)
        dim_names = [".".join(dns) for dns in self.domain.flatten()]
        self._table.column_headers = ["No.", *dim_names, *self.metrics]
github abulka / pynsource / src / parsing / dump_pmodel.py View on Github external
have_display_module_methods_once = False

    for classname, classentry in sorted(
        list(pmodel.classlist.items()), key=lambda kv: calc_classname(kv[1])
    ):
        # Work out sub-tables first

        if classentry.classdependencytuples:
            t2 = BeautifulTable()
            for _from,_to in classentry.classdependencytuples:
                t2.append_row([_from,_to])
        else:
            t2 = ""

        if classentry.attrs:
            t3 = BeautifulTable()
            t3.column_headers = ["name", "type"]
            t3.column_alignments["name"] = BeautifulTable.ALIGN_LEFT
            t3.row_separator_char = ""
            for attrobj in classentry.attrs:
                t3.append_row([attrobj.attrname, "\n".join(attrobj.attrtype)])
        else:
            t3 = ""

        # t4 = BeautifulTable()
        # t4.column_headers = ["of class", "of module"]
        # t4.column_alignments["of class"] = BeautifulTable.ALIGN_LEFT
        # t4.column_alignments["of module"] = BeautifulTable.ALIGN_LEFT
        # t4.row_separator_char = ""
        # t4.append_row(["\n".join(classentry.defs), "\n".join(pmodel.modulemethods)])

        t.append_row(
github Cloud-CV / evalai-cli / evalai / utils / challenges.py View on Github external
def pretty_print_challenge_data(challenges):
    """
    Function to print the challenge data
    """
    table = BeautifulTable(max_width=200)
    attributes = ["id", "title", "short_description"]
    columns_attributes = [
        "ID",
        "Title",
        "Short Description",
        "Creator",
        "Start Date",
        "End Date",
    ]
    table.column_headers = columns_attributes
    for challenge in reversed(challenges):
        values = list(map(lambda item: challenge[item], attributes))
        creator = challenge["creator"]["team_name"]
        start_date = convert_UTC_date_to_local(challenge["start_date"])
        end_date = convert_UTC_date_to_local(challenge["end_date"])
        values.extend([creator, start_date, end_date])
github Cloud-CV / evalai-cli / evalai / utils / challenges.py View on Github external
def pretty_print_challenge_phase_split_data(phase_splits):
    """
    Function to print the details of a Challenge Phase Split.
    """
    table = BeautifulTable(max_width=100)
    attributes = ["id", "dataset_split_name", "challenge_phase_name"]
    columns_attributes = [
        "Challenge Phase ID",
        "Dataset Split",
        "Challenge Phase Name",
    ]
    table.column_headers = columns_attributes

    for split in phase_splits:
        if split["visibility"] == 3:
            values = list(map(lambda item: split[item], attributes))
            table.append_row(values)
    echo(table)
github abulka / pynsource / src / layout / coordinate_mapper.py View on Github external
def DumpCalibrationInfo(
        self, dump_mode=None, new_world_size=None, scale=None, dump_nodes=True, doprint=True
    ):

        t = BeautifulTable()
        # t.column_headers = ["items", "info1", "info2"]

        if dump_mode == "is_function_start":
            t.append_row(
                [
                    "CoordinateMapper.Recalibrate START, calling with: new_world_size, scale",
                    new_world_size,
                    scale,
                ]
            )
        elif dump_mode == "is_function_end":
            t.append_row(["CoordinateMapper.Recalibrate END", "", ""])

        t.append_row(["scale and radius", self.scale, self.radius])

        # subtable support not yet released, cos of newline support issue in beautifuletable
github Cloud-CV / evalai-cli / evalai / utils / teams.py View on Github external
def pretty_print_team_data(teams, is_host):
    """
    Function to print the team data
    """
    table = BeautifulTable(max_width=200)
    attributes = ["id", "team_name", "created_by"]
    columns_attributes = [
        "ID",
        "Team Name",
        "Created By",
        "Members",
        "Team URL",
    ]
    table.column_headers = columns_attributes
    for team in teams:
        values = list(map(lambda item: team[item], attributes))
        if is_host:
            members = ", ".join(
                map(lambda member: member["user"], team["members"])
            )
        else:
github Accenture / AmpliGraph / experiments / predictive_performance.py View on Github external
def display_scores(scores):
    output_readme = {}
    output_rst = {}

    for obj in scores:
        output_rst[obj["dataset"]] = BeautifulTable()
        output_rst[obj["dataset"]].set_style(BeautifulTable.STYLE_RST)
        output_rst[obj["dataset"]].column_headers = \
            ["Model", "MR", "MRR", "Hits@1", \
             "Hits@3", "Hits@10", "Time (s)", "ES epochs", "Hyperparameters"]

    for obj in scores:
        try:
            output_rst[obj["dataset"]] \
                .append_row([obj["model"],
                             "{0:.1f}".format(obj["mr"]),
                             "{0:.4f}".format(obj["mrr"]),
                             "{0:.3f}".format(obj["H@1"]),
                             "{0:.3f}".format(obj["H@3"]),
                             "{0:.3f}".format(obj["H@10"]),
                             "{0:.1f}".format(obj["time"]),
                             "{}".format(obj["early_stopping_epoch"]),
                             yaml.dump(obj["hyperparams"],