UnitConverter package

Submodules

UnitConverter.UnitConverter module

This module will let you convert one measurement unit to another.

class UnitConverter.UnitConverter.BaseUnitConverter[source]

Bases: object

The base class. It has the five main conversion types

Area(unitFrom: str, unitTo: str)[source]

Area conversion method

Args:
amount (float) - amount of current units
unitFrom (string) - current unit
unitTo (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 units
unitFrom (string) - current unit
unitTo (string) - new unit
Units (string array) - array of all supported units that can be converted to each other
Matrix (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 units
unitFrom (string) - current unit
unitTo (string) - new unit
Returns:
float - conversion result
Time(unitFrom: str, unitTo: str)[source]

Time conversion method

Args:
amount (float) - amount of current units
unitFrom (string) - current unit
unitTo (string) - new unit
Returns:
float - conversion result
Volume(unitFrom: str, unitTo: str)[source]

Volume conversion method

Args:
amount (float) - amount of current units
unitFrom (string) - current unit
unitTo (string) - new unit
Returns:
float - conversion result
Weight(unitFrom: str, unitTo: str)[source]

Weight conversion method

Args:
amount (float) - amount of current units
unitFrom (string) - current unit
unitTo (string) - new unit
Returns:
float - conversion result
class UnitConverter.UnitConverter.CustomConverter(Units: str, Matrix: float)[source]

Bases: object

The 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 other
Matrix (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 unit
unitTo (string) - new unit
Conversion (float) - conversion coefficient
Convert(amount: float, unitFrom: str, unitTo: str)[source]

Unit conversion method.

Args:
amount (float) - amount of current units
unitFrom (string) - current unit
unitTo (string) - new unit
Returns:
float - conversion result
Print(Units: bool = False, Matrix: bool = False)[source]

Converter parameter print method

Args:
Units (bool) - Should it print the units?
Matrix (bool) - Should it print the matrix?

Module contents