roseau.load_flow._wrapper#

Module Contents#

Functions#

wraps(→ collections.abc.Callable[[FuncT], FuncT])

Wraps a function to become pint-aware.

wraps(ureg: UnitRegistry, ret: str | Unit | Iterable[str | Unit | None] | None, args: str | Unit | Iterable[str | Unit | None] | None) Callable[[FuncT], FuncT]#

Wraps a function to become pint-aware.

Use it when a function requires a numerical value but in some specific units. The wrapper function will take a pint quantity, convert to the units specified in args and then call the wrapped function with the resulting magnitude.

The value returned by the wrapped function will be converted to the units specified in ret.

Parameters:
  • ureg – A UnitRegistry instance.

  • ret – Units of each of the return values. Use None to skip argument conversion.

  • args – Units of each of the input arguments. Use None to skip argument conversion.

Returns:

The wrapper function.

Raises:

TypeError – if the number of given arguments does not match the number of function parameters. if any of the provided arguments is not a unit a string or Quantity