caellion-python-commons: caellion.pycommons.stringutil.formatters.NumberFormatting Class Reference

caellion-python-commons

Public Member Functions | List of all members
caellion.pycommons.stringutil.formatters.NumberFormatting Class Reference

This class provides various number formats. More...

## Public Member Functions
def | formatSI (v, dec=0)
| Formats number as an SI-prefixed decimal. More...
def | formatBinarySI (v, dec=0)
| Formats number as an SI-prefixed decimal, using binary unit prefixes (ki, Mi, etc.) More...
def | formatSISubValue (v, dec=0)
| Formats less-than-one numbers to an SI-prefixed decimal (using prefixes like m, μ) More...
def | formatSIBinarySubValue (v, dec=0)
| Formats fractional number to SI-prefixed decimal using binary unit prefixes. More...
def | formatSIFullRange (v, dec)
| Formats number using full range (will format numbers below 1 with subvalue variant) using SI decimal unit prefixes. More...
def | formatUnitsPerIntervalDynamic (units, seconds, unit)
| Generates an expression like "1.0kg/year". More...

## Detailed Description

This class provides various number formats.

Definition at line 16 of file formatters.py.

## Member Function Documentation

## ◆ formatBinarySI()

def caellion.pycommons.stringutil.formatters.NumberFormatting.formatBinarySI | ( |  | v,
|  |  | dec = `0`
| ) |  |

Formats number as an SI-prefixed decimal, using binary unit prefixes (ki, Mi, etc.)

Parameters

  v | Number to be formatted
  dec | Number of decimal places

Returns
  formatted string

Definition at line 50 of file formatters.py.

## ◆ formatSI()

def caellion.pycommons.stringutil.formatters.NumberFormatting.formatSI | ( |  | v,
|  |  | dec = `0`
| ) |  |

Formats number as an SI-prefixed decimal.

Parameters

  v | Number to be formatted
  dec | Number of decimal places

Returns
  formatted string

Definition at line 21 of file formatters.py.

## ◆ formatSIBinarySubValue()

def caellion.pycommons.stringutil.formatters.NumberFormatting.formatSIBinarySubValue | ( |  | v,
|  |  | dec = `0`
| ) |  |

Formats fractional number to SI-prefixed decimal using binary unit prefixes.

Warning
  This is not supported

Definition at line 111 of file formatters.py.

## ◆ formatSIFullRange()

def caellion.pycommons.stringutil.formatters.NumberFormatting.formatSIFullRange | ( |  | v,
|  |  | dec
| ) |  |

Formats number using full range (will format numbers below 1 with subvalue variant) using SI decimal unit prefixes.

Parameters

  v | Number to be formatted
  dec | Number of decimal places

Returns
  formatted string

Definition at line 120 of file formatters.py.

## ◆ formatSISubValue()

def caellion.pycommons.stringutil.formatters.NumberFormatting.formatSISubValue | ( |  | v,
|  |  | dec = `0`
| ) |  |

Formats less-than-one numbers to an SI-prefixed decimal (using prefixes like m, μ)

Parameters

  v | Number to be formatted
  dec | Number of decimal places

Returns
  formatted string

Definition at line 80 of file formatters.py.

## ◆ formatUnitsPerIntervalDynamic()

def caellion.pycommons.stringutil.formatters.NumberFormatting.formatUnitsPerIntervalDynamic | ( |  | units,
|  |  | seconds,
|  |  | unit
| ) |  |

Generates an expression like "1.0kg/year".

Parameters

  units | amount of units that have happened over measurement interval
  seconds | measurement interval, expressed in seconds
  unit | name of unit (kg in example above)

Returns
  formatted string, expression like "1.0kg/year"

Definition at line 134 of file formatters.py.

The documentation for this class was generated from the following file:

- caellion/pycommons/stringutil/formatters.py