pudl_diff.formatting
¶
Human-readable formatting of sizes, durations, and percentages.
format_bytes(num_bytes, *, signed=False)
¶
Format a byte count in decimal units, e.g. 21.4 GB or 512 B.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_bytes
|
int
|
The size to format. May be negative, for a change in size. |
required |
signed
|
bool
|
Whether to prefix a positive size with |
False
|
Source code in src/pudl_diff/formatting.py
format_duration(seconds)
¶
Format the duration of a whole run, which may be minutes or hours long.
Source code in src/pudl_diff/formatting.py
format_elapsed(seconds)
¶
format_percent(count, total)
¶
count as a percentage of total, with useful precision when small.
Source code in src/pudl_diff/formatting.py
format_signed_percent(percent)
¶
A percentage change, always signed, with useful precision when small.