Skip to content

Compact formatting breaks table ordering #539

@jmelburg

Description

@jmelburg

pdstools version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pdstools.

Issue description

    def _format_compact(self, num: float) -> str:
        """Format in compact notation (K/M/B/T)."""
        if num == 0:
            return "0"

        abs_num = abs(num)
        for threshold, suffix in [(1e12, "T"), (1e9, "B"), (1e6, "M"), (1e3, "K")]:
            if abs_num >= threshold:
                return f"{num / threshold:,.{self.decimals}f}{suffix}"
        return f"{num:,.{self.decimals}f}"

returns numbers as strings, which does not work nicely in tables such as on dsi.

Reproducible example

visit dsi, order on number of actions

Expected behavior

4k > 500 when ordering the table

Installed versions

Details

Metadata

Metadata

Assignees

Labels

PythonIssues related to the Python toolsbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions