UnknownUnit

class justunits.UnknownUnit(unit_text: str, switch_power: bool = False, was_enclosed: bool = False)

The unknown unit appears for cases in which text could not be resolved to units known by the current runtime library.

Parameters
  • unit_text – Text for which no ‘known’ unit could be found.

  • switch_power – States whether the unit would need to switch power due to division.

  • was_enclosed – States if the unit text was enclosed by round brackets.

Examples

Fruits are definitivelly unknown to the unit library.

>>> import justunits
>>> justunits.from_string("pear/apple")
(UnknownUnit('pear'), UnknownUnit('apple' *^-1))

Any unknown occurance can be registered.

>>> justunits.register_unit(justunits.create_unit("pear", "pear", "fruit"))
>>> justunits.from_string("pear/apple")
(AUnit(pear 'pear' fruit), UnknownUnit('apple' *^-1))