Skip to content

trulens.core.utils.text

trulens.core.utils.text

Utilities for user-facing text generation.

Functions

format_quantity

format_quantity(quantity: float, precision: int = 2) -> str

Format a quantity into a human-readable string. This will use SI prefixes. Implementation details are largely copied from millify.

PARAMETER DESCRIPTION
quantity

The quantity to format.

TYPE: float

precision

The precision to use. Defaults to 2.

TYPE: int DEFAULT: 2

RETURNS DESCRIPTION
str

The formatted quantity.

TYPE: str

format_seconds

format_seconds(seconds: float, precision: int = 2) -> str

Format seconds into human-readable time. This only goes up to days.

PARAMETER DESCRIPTION
seconds

The number of seconds to format.

TYPE: float

precision

The precision to use. Defaults to 2.

TYPE: int DEFAULT: 2

RETURNS DESCRIPTION
str

The formatted time.

TYPE: str