UnitConverter package
Submodules
UnitConverter.UnitConverter module
This module will let you convert one measurement unit to another.
- class UnitConverter.UnitConverter.BaseUnitConverter[source]
Bases:
objectThe base class. It has the five main conversion types
- Area(unitFrom: str, unitTo: str)[source]
Area conversion method
- Args:
- amount (float) - amount of current unitsunitFrom (string) - current unitunitTo (string) - new unit
- Returns:
- float - conversion result
- Convert(unitFrom: str, unitTo: str, Units: str, Matrix: float)[source]
This method does the conversion from the current unit to the new unit. You can use it if you want to define your own custom conversions.
- Args:
- amount (float) - amount of current unitsunitFrom (string) - current unitunitTo (string) - new unitUnits (string array) - array of all supported units that can be converted to each otherMatrix (float matrix) - conversion matrix at the size of [Units][Units]
- Returns:
- float - conversion result
- Length(unitFrom: str, unitTo: str)[source]
Length conversion method
- Args:
- amount (float) - amount of current unitsunitFrom (string) - current unitunitTo (string) - new unit
- Returns:
- float - conversion result
- Time(unitFrom: str, unitTo: str)[source]
Time conversion method
- Args:
- amount (float) - amount of current unitsunitFrom (string) - current unitunitTo (string) - new unit
- Returns:
- float - conversion result
- class UnitConverter.UnitConverter.CustomConverter(Units: str, Matrix: float)[source]
Bases:
objectThe customizable unit converter class
- Change(Units: Optional[str] = None, Matrix: Optional[float] = None)[source]
Converter parameter change method. Both arguments are optional.
- Args:
- Units (string array) - array of all supported units that can be converted to each otherMatrix (float matrix) - conversion matrix at the size of [Units][Units]
- ChangeSingle(UnitFrom: str, UnitTo: str, Conversion: float)[source]
Single conversion change method
- Args:
- unitFrom (string) - current unitunitTo (string) - new unitConversion (float) - conversion coefficient