caellion-python-commons
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
vNumber to be formatted
decNumber 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
vNumber to be formatted
decNumber 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
vNumber to be formatted
decNumber 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
vNumber to be formatted
decNumber 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
unitsamount of units that have happened over measurement interval
secondsmeasurement interval, expressed in seconds
unitname 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: