Units

While nearly all unit functionality is handled internally within Sympl, it does expose a few helper functions which may be useful to you.

sympl.is_valid_unit(unit_string)[source]

Returns True if the unit string is recognized, and False otherwise.

sympl.units_are_same(unit1, unit2)[source]

Compare two unit strings for equality.

Parameters:
  • unit1 (str) –
  • unit2 (str) –
Returns:

units_are_same – True if the two input unit strings represent the same unit.

Return type:

bool

sympl.units_are_compatible(unit1, unit2)[source]

Determine whether a unit can be converted to another unit.

Parameters:
  • unit1 (str) –
  • unit2 (str) –
Returns:

units_are_compatible – True if the first unit can be converted to the second unit.

Return type:

bool