fgen_runtime.units#
Unit-handling
UnitDefinition#
ReturnUnitDefinition#
VerifyUnitsSupported#
Q#
PintSupported#
- PintSupported#
Types that are able to be cast to
pint.registry.UnitRegistry.Quantity
by pintalias 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:
ret (
typing.Union
[str
,pint.registry.Unit
,None
,collections.abc.Iterable
[typing.Union
[str
,pint.registry.Unit
,None
]]]) – Units of each of the return values. Use None to skip argument conversion.args (
collections.abc.Iterable
[typing.Union
[str
,pint.registry.Unit
,None
]]) – Units of each of the arguments. Use None to skip argument conversion.strict (
bool
) – Indicates that only quantities are accepted. (Default value = True)ureg (
typing.Optional
[pint.registry.UnitRegistry
]) –Unit registry to use
Defaults to
unit_registry
in the fgen.units module.
- Returns:
typing.Callable
[[typing.Callable
[...
,typing.Any
]],typing.Callable
[...
,typing.Any
]] – Decorator for wrapping callables