vcorelib.math.unit
index
/home/vkottler/src/vkottler/workspace/vcorelib/vcorelib/math/unit.py

A module for working with units.

 
Modules
       
typing

 
Classes
       
builtins.tuple(builtins.object)
UnitSystem

 
class UnitSystem(builtins.tuple)
    UnitSystem(prefixes: Sequence[str], divisor: int)
 
A pairing of prefixes defining a unit, and the amount that indicates the
multiplicative step-size between them.
 
 
Method resolution order:
UnitSystem
builtins.tuple
builtins.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new dict which maps field names to their values.
_replace(self, /, **kwds)
Return a new UnitSystem object replacing specified fields with new values

Class methods defined here:
_make(iterable) from builtins.type
Make a new UnitSystem object from a sequence or iterable

Static methods defined here:
__new__(_cls, prefixes: Sequence[str], divisor: int)
Create new instance of UnitSystem(prefixes, divisor)

Data descriptors defined here:
prefixes
Alias for field number 0
divisor
Alias for field number 1

Data and other attributes defined here:
__annotations__ = {'divisor': <class 'int'>, 'prefixes': typing.Sequence[str]}
__match_args__ = ('prefixes', 'divisor')
__orig_bases__ = (<function NamedTuple>,)
_field_defaults = {}
_fields = ('prefixes', 'divisor')

Methods inherited from builtins.tuple:
__add__(self, value, /)
Return self+value.
__contains__(self, key, /)
Return bool(key in self).
__eq__(self, value, /)
Return self==value.
__ge__(self, value, /)
Return self>=value.
__getattribute__(self, name, /)
Return getattr(self, name).
__getitem__(self, key, /)
Return self[key].
__gt__(self, value, /)
Return self>value.
__hash__(self, /)
Return hash(self).
__iter__(self, /)
Implement iter(self).
__le__(self, value, /)
Return self<=value.
__len__(self, /)
Return len(self).
__lt__(self, value, /)
Return self<value.
__mul__(self, value, /)
Return self*value.
__ne__(self, value, /)
Return self!=value.
__rmul__(self, value, /)
Return value*self.
count(self, value, /)
Return number of occurrences of value.
index(self, value, start=0, stop=9223372036854775807, /)
Return first index of value.
 
Raises ValueError if the value is not present.

Class methods inherited from builtins.tuple:
__class_getitem__(...) from builtins.type
See PEP 585

 
Functions
       
unit_traverse(val: int, unit: vcorelib.math.unit.UnitSystem = UnitSystem(prefixes=['n', 'u', 'm', '', 'k', 'M', 'G', 'T'], divisor=1000), max_prefix: int = 3, iteration: int = 0) -> Tuple[int, int, str]
Given an initial value, traverse a unit system to get the largest
representative unit prefix. Also return a fractional component, in units
of the next-smallest prefix.

 
Data
        KIBI_UNITS = UnitSystem(prefixes=['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'], divisor=1024)
SI_UNITS = UnitSystem(prefixes=['n', 'u', 'm', '', 'k', 'M', 'G', 'T'], divisor=1000)