formatters
¶
Formatters are mappings from object(s) to a string.
Functions:¶
list_args(func)
¶
Extend the function to allow taking a list as the first argument, and apply the function on each of the elements.
Args: func: the function to extend
Returns: The extended function
fmt_color(text, color)
¶
Format a string in a certain color (<span>).
Args: text: The text to format. color: Any valid CSS color.
Returns:
A <span> that contains the colored text.
fmt_class(text, cls)
¶
Format a string in a certain class (<span>).
Args: text: The text to format. cls: The name of the class.
Returns:
A <span> with a class added.
fmt_bytesize(num, suffix='B')
¶
Change a number of bytes in a human-readable format.
Args: num: number to format suffix: (Default value = 'B')
Returns: The value formatted in human readable format (e.g. KiB).
fmt_percent(value, edge_cases=True)
¶
Format a ratio as a percentage.
Args: edge_cases: Check for edge cases? value: The ratio.
Returns: The percentage with 1 point precision.
fmt_numeric(value, precision=10)
¶
Format any numeric value.
Args: value: The numeric value to format. precision: The numeric precision
Returns: The numeric value with the given precision.
fmt_number(value)
¶
Format any numeric value.
Args: value: The numeric value to format.
Returns: The numeric value with the given precision.
fmt_array(value, threshold=np.nan)
¶
Format numpy arrays.
Args: value: Array to format. threshold: Threshold at which to show ellipsis
Returns: The string representation of the numpy array.
fmt(value)
¶
Format any value.
Args: value: The value to format.
Returns: The numeric formatting if the value is float or int, the string formatting otherwise.
help(title, url=None)
¶
Creat help badge
Args: title: help text url: url to open in new tab (optional)
Returns: HTML formatted help badge