fgen_runtime.units#

Unit-handling

UnitDefinition#

UnitDefinition#

Types which can be used to specify the exepcted (input) unit

alias of Union[str, Unit]

ReturnUnitDefinition#

ReturnUnitDefinition#

Types which can be used to specify the exepcted return unit

alias of Union[str, tuple[str, …], Unit, tuple[Unit, …]]

VerifyUnitsSupported#

VerifyUnitsSupported#

Types which are supported as inputs to verify_units()

alias of Optional[Union[str, Unit]]

Q#

Q: TypeAlias = <class 'pint.registry.Quantity'>#

Short-hand to save space and typing

PintSupported#

PintSupported#

Types that are able to be cast to pint.registry.UnitRegistry.Quantity by pint

alias of Union[float, int, number[Any], ndarray[Any, dtype[number[Any]]], _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]

verify_units#

verify_units(ret, args, strict=True, ureg=None)[source]#

Wrap a function to make it pint-aware

This wraps unit_registry.wraps(), but provides better handling for types

Parameters:
Returns:

typing.Callable[[typing.Callable[..., typing.Any]], typing.Callable[..., typing.Any]] – Decorator for wrapping callables